Add flow steering actions: modify header and packet reformat to the fs_cmd shim layer. This allows each namespace to define possibly different functionality for alloc/dealloc action commands.
Unified · Split
| @@ -322,11 +322,11 @@ void mlx5_ib_destroy_flow_action_raw(struct mlx5_ib_flow_action *maction) · 321 unmodified lines | |||
| 322 | switch (maction->flow_action_raw.sub_type) { | 322 | switch (maction->flow_action_raw.sub_type) { |
| 323 | case MLX5_IB_FLOW_ACTION_MODIFY_HEADER: | 323 | case MLX5_IB_FLOW_ACTION_MODIFY_HEADER: |
| 324 | mlx5_modify_header_dealloc(maction->flow_action_raw.dev->mdev, | 324 | mlx5_modify_header_dealloc(maction->flow_action_raw.dev->mdev, |
| 325 | maction->flow_action_raw.action_id); | 325 | maction->flow_action_raw.modify_hdr); |
| 326 | break; | 326 | break; |
| 327 | case MLX5_IB_FLOW_ACTION_PACKET_REFORMAT: | 327 | case MLX5_IB_FLOW_ACTION_PACKET_REFORMAT: |
| 328 | mlx5_packet_reformat_dealloc(maction->flow_action_raw.dev->mdev, | 328 | mlx5_packet_reformat_dealloc(maction->flow_action_raw.dev->mdev, |
| 329 | maction->flow_action_raw.action_id); | 329 | maction->flow_action_raw.pkt_reformat); |
| 330 | break; | 330 | break; |
| 331 | case MLX5_IB_FLOW_ACTION_DECAP: | 331 | case MLX5_IB_FLOW_ACTION_DECAP: |
| 332 | break; | 332 | break; |
| @@ -352,10 +352,11 @@ mlx5_ib_create_modify_header(struct mlx5_ib_dev *dev, · 19 unmodified lines | |||
| 352 | if (!maction) | 352 | if (!maction) |
| 353 | return ERR_PTR(-ENOMEM); | 353 | return ERR_PTR(-ENOMEM); |
| 354 | 354 | ||
| 355 | ret = mlx5_modify_header_alloc(dev->mdev, namespace, num_actions, in, | 355 | maction->flow_action_raw.modify_hdr = |
| 356 | &maction->flow_action_raw.action_id); | 356 | mlx5_modify_header_alloc(dev->mdev, namespace, num_actions, in); |
| 357 | 357 | ||
| 358 | if (ret) { | 358 | if (IS_ERR(maction->flow_action_raw.modify_hdr)) { |
| 359 | ret = PTR_ERR(maction->flow_action_raw.modify_hdr); | ||
| 359 | kfree(maction); | 360 | kfree(maction); |
| 360 | return ERR_PTR(ret); | 361 | return ERR_PTR(ret); |
| 361 | } | 362 | } |
| @@ -479,11 +480,13 @@ static int mlx5_ib_flow_action_create_packet_reformat_ctx( · 117 unmodified lines | |||
| 479 | if (ret) | 480 | if (ret) |
| 480 | return ret; | 481 | return ret; |
| 481 | 482 | ||
| 482 | ret = mlx5_packet_reformat_alloc(dev->mdev, prm_prt, len, | 483 | maction->flow_action_raw.pkt_reformat = |
| 483 | in, namespace, | 484 | mlx5_packet_reformat_alloc(dev->mdev, prm_prt, len, |
| 484 | &maction->flow_action_raw.action_id); | 485 | in, namespace); |
| 485 | if (ret) | 486 | if (IS_ERR(maction->flow_action_raw.pkt_reformat)) { |
| 487 | ret = PTR_ERR(maction->flow_action_raw.pkt_reformat); | ||
| 486 | return ret; | 488 | return ret; |
| 489 | } | ||
| 487 | 490 | ||
| 488 | maction->flow_action_raw.sub_type = | 491 | maction->flow_action_raw.sub_type = |
| 489 | MLX5_IB_FLOW_ACTION_PACKET_REFORMAT; | 492 | MLX5_IB_FLOW_ACTION_PACKET_REFORMAT; |
| @@ -2658,7 +2658,8 @@ int parse_flow_flow_action(struct mlx5_ib_flow_action *maction, · 2657 unmodified lines | |||
| 2658 | if (action->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) | 2658 | if (action->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) |
| 2659 | return -EINVAL; | 2659 | return -EINVAL; |
| 2660 | action->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; | 2660 | action->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; |
| 2661 | action->modify_id = maction->flow_action_raw.action_id; | 2661 | action->modify_hdr = |
| 2662 | maction->flow_action_raw.modify_hdr; | ||
| 2662 | return 0; | 2663 | return 0; |
| 2663 | } | 2664 | } |
| 2664 | if (maction->flow_action_raw.sub_type == | 2665 | if (maction->flow_action_raw.sub_type == |
| @@ -2675,8 +2676,8 @@ int parse_flow_flow_action(struct mlx5_ib_flow_action *maction, · 10 unmodified lines | |||
| 2675 | return -EINVAL; | 2676 | return -EINVAL; |
| 2676 | action->action |= | 2677 | action->action |= |
| 2677 | MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; | 2678 | MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; |
| 2678 | action->reformat_id = | 2679 | action->pkt_reformat = |
| 2679 | maction->flow_action_raw.action_id; | 2680 | maction->flow_action_raw.pkt_reformat; |
| 2680 | return 0; | 2681 | return 0; |
| 2681 | } | 2682 | } |
| 2682 | /* fall through */ | 2683 | /* fall through */ |
| @@ -868,7 +868,10 @@ struct mlx5_ib_flow_action { · 867 unmodified lines | |||
| 868 | struct { | 868 | struct { |
| 869 | struct mlx5_ib_dev *dev; | 869 | struct mlx5_ib_dev *dev; |
| 870 | u32 sub_type; | 870 | u32 sub_type; |
| 871 | u32 action_id; | 871 | union { |
| 872 | struct mlx5_modify_hdr *modify_hdr; | ||
| 873 | struct mlx5_pkt_reformat *pkt_reformat; | ||
| 874 | }; | ||
| 872 | } flow_action_raw; | 875 | } flow_action_raw; |
| 873 | }; | 876 | }; |
| 874 | }; | 877 | }; |
| @@ -291,14 +291,14 @@ int mlx5e_tc_tun_create_header_ipv4(struct mlx5e_priv *priv, · 290 unmodified lines | |||
| 291 | */ | 291 | */ |
| 292 | goto out; | 292 | goto out; |
| 293 | } | 293 | } |
| 294 | 294 | e->pkt_reformat = mlx5_packet_reformat_alloc(priv->mdev, | |
| 295 | err = mlx5_packet_reformat_alloc(priv->mdev, | 295 | e->reformat_type, |
| 296 | e->reformat_type, | 296 | ipv4_encap_size, encap_header, |
| 297 | ipv4_encap_size, encap_header, | 297 | MLX5_FLOW_NAMESPACE_FDB); |
| 298 | MLX5_FLOW_NAMESPACE_FDB, | 298 | if (IS_ERR(e->pkt_reformat)) { |
| 299 | &e->encap_id); | 299 | err = PTR_ERR(e->pkt_reformat); |
| 300 | if (err) | ||
| 301 | goto destroy_neigh_entry; | 300 | goto destroy_neigh_entry; |
| 301 | } | ||
| 302 | 302 | ||
| 303 | e->flags |= MLX5_ENCAP_ENTRY_VALID; | 303 | e->flags |= MLX5_ENCAP_ENTRY_VALID; |
| 304 | mlx5e_rep_queue_neigh_stats_work(netdev_priv(out_dev)); | 304 | mlx5e_rep_queue_neigh_stats_work(netdev_priv(out_dev)); |
| @@ -407,13 +407,14 @@ int mlx5e_tc_tun_create_header_ipv6(struct mlx5e_priv *priv, · 102 unmodified lines | |||
| 407 | goto out; | 407 | goto out; |
| 408 | } | 408 | } |
| 409 | 409 | ||
| 410 | err = mlx5_packet_reformat_alloc(priv->mdev, | 410 | e->pkt_reformat = mlx5_packet_reformat_alloc(priv->mdev, |
| 411 | e->reformat_type, | 411 | e->reformat_type, |
| 412 | ipv6_encap_size, encap_header, | 412 | ipv6_encap_size, encap_header, |
| 413 | MLX5_FLOW_NAMESPACE_FDB, | 413 | MLX5_FLOW_NAMESPACE_FDB); |
| 414 | &e->encap_id); | 414 | if (IS_ERR(e->pkt_reformat)) { |
| 415 | if (err) | 415 | err = PTR_ERR(e->pkt_reformat); |
| 416 | goto destroy_neigh_entry; | 416 | goto destroy_neigh_entry; |
| 417 | } | ||
| 417 | 418 | ||
| 418 | e->flags |= MLX5_ENCAP_ENTRY_VALID; | 419 | e->flags |= MLX5_ENCAP_ENTRY_VALID; |
| 419 | mlx5e_rep_queue_neigh_stats_work(netdev_priv(out_dev)); | 420 | mlx5e_rep_queue_neigh_stats_work(netdev_priv(out_dev)); |
| @@ -161,7 +161,7 @@ struct mlx5e_encap_entry { · 160 unmodified lines | |||
| 161 | */ | 161 | */ |
| 162 | struct hlist_node encap_hlist; | 162 | struct hlist_node encap_hlist; |
| 163 | struct list_head flows; | 163 | struct list_head flows; |
| 164 | u32 encap_id; | 164 | struct mlx5_pkt_reformat *pkt_reformat; |
| 165 | const struct ip_tunnel_info *tun_info; | 165 | const struct ip_tunnel_info *tun_info; |
| 166 | unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ | 166 | unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ |
| 167 | 167 | ||
| @@ -61,7 +61,7 @@ · 60 unmodified lines | |||
| 61 | struct mlx5_nic_flow_attr { | 61 | struct mlx5_nic_flow_attr { |
| 62 | u32 action; | 62 | u32 action; |
| 63 | u32 flow_tag; | 63 | u32 flow_tag; |
| 64 | u32 mod_hdr_id; | 64 | struct mlx5_modify_hdr *modify_hdr; |
| 65 | u32 hairpin_tirn; | 65 | u32 hairpin_tirn; |
| 66 | u8 match_level; | 66 | u8 match_level; |
| 67 | struct mlx5_flow_table *hairpin_ft; | 67 | struct mlx5_flow_table *hairpin_ft; |
| @@ -201,7 +201,7 @@ struct mlx5e_mod_hdr_entry { · 133 unmodified lines | |||
| 201 | 201 | ||
| 202 | struct mod_hdr_key key; | 202 | struct mod_hdr_key key; |
| 203 | 203 | ||
| 204 | u32 mod_hdr_id; | 204 | struct mlx5_modify_hdr *modify_hdr; |
| 205 | 205 | ||
| 206 | refcount_t refcnt; | 206 | refcount_t refcnt; |
| 207 | struct completion res_ready; | 207 | struct completion res_ready; |
| @@ -334,7 +334,7 @@ static void mlx5e_mod_hdr_put(struct mlx5e_priv *priv, · 126 unmodified lines | |||
| 334 | 334 | ||
| 335 | WARN_ON(!list_empty(&mh->flows)); | 335 | WARN_ON(!list_empty(&mh->flows)); |
| 336 | if (mh->compl_result > 0) | 336 | if (mh->compl_result > 0) |
| 337 | mlx5_modify_header_dealloc(priv->mdev, mh->mod_hdr_id); | 337 | mlx5_modify_header_dealloc(priv->mdev, mh->modify_hdr); |
| 338 | 338 | ||
| 339 | kfree(mh); | 339 | kfree(mh); |
| 340 | } | 340 | } |
| @@ -395,11 +395,11 @@ static int mlx5e_attach_mod_hdr(struct mlx5e_priv *priv, · 54 unmodified lines | |||
| 395 | hash_add(tbl->hlist, &mh->mod_hdr_hlist, hash_key); | 395 | hash_add(tbl->hlist, &mh->mod_hdr_hlist, hash_key); |
| 396 | mutex_unlock(&tbl->lock); | 396 | mutex_unlock(&tbl->lock); |
| 397 | 397 | ||
| 398 | err = mlx5_modify_header_alloc(priv->mdev, namespace, | 398 | mh->modify_hdr = mlx5_modify_header_alloc(priv->mdev, namespace, |
| 399 | mh->key.num_actions, | 399 | mh->key.num_actions, |
| 400 | mh->key.actions, | 400 | mh->key.actions); |
| 401 | &mh->mod_hdr_id); | 401 | if (IS_ERR(mh->modify_hdr)) { |
| 402 | if (err) { | 402 | err = PTR_ERR(mh->modify_hdr); |
| 403 | mh->compl_result = err; | 403 | mh->compl_result = err; |
| 404 | goto alloc_header_err; | 404 | goto alloc_header_err; |
| 405 | } | 405 | } |
| @@ -412,9 +412,9 @@ attach_flow: · 6 unmodified lines | |||
| 412 | list_add(&flow->mod_hdr, &mh->flows); | 412 | list_add(&flow->mod_hdr, &mh->flows); |
| 413 | spin_unlock(&mh->flows_lock); | 413 | spin_unlock(&mh->flows_lock); |
| 414 | if (mlx5e_is_eswitch_flow(flow)) | 414 | if (mlx5e_is_eswitch_flow(flow)) |
| 415 | flow->esw_attr->mod_hdr_id = mh->mod_hdr_id; | 415 | flow->esw_attr->modify_hdr = mh->modify_hdr; |
| 416 | else | 416 | else |
| 417 | flow->nic_attr->mod_hdr_id = mh->mod_hdr_id; | 417 | flow->nic_attr->modify_hdr = mh->modify_hdr; |
| 418 | 418 | ||
| 419 | return 0; | 419 | return 0; |
| 420 | 420 | ||
| @@ -906,7 +906,6 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv, · 485 unmodified lines | |||
| 906 | struct mlx5_flow_destination dest[2] = {}; | 906 | struct mlx5_flow_destination dest[2] = {}; |
| 907 | struct mlx5_flow_act flow_act = { | 907 | struct mlx5_flow_act flow_act = { |
| 908 | .action = attr->action, | 908 | .action = attr->action, |
| 909 | .reformat_id = 0, | ||
| 910 | .flags = FLOW_ACT_NO_APPEND, | 909 | .flags = FLOW_ACT_NO_APPEND, |
| 911 | }; | 910 | }; |
| 912 | struct mlx5_fc *counter = NULL; | 911 | struct mlx5_fc *counter = NULL; |
| @@ -947,7 +946,7 @@ mlx5e_tc_add_nic_flow(struct mlx5e_priv *priv, · 34 unmodified lines | |||
| 947 | 946 | ||
| 948 | if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) { | 947 | if (attr->action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) { |
| 949 | err = mlx5e_attach_mod_hdr(priv, flow, parse_attr); | 948 | err = mlx5e_attach_mod_hdr(priv, flow, parse_attr); |
| 950 | flow_act.modify_id = attr->mod_hdr_id; | 949 | flow_act.modify_hdr = attr->modify_hdr; |
| 951 | kfree(parse_attr->mod_hdr_actions); | 950 | kfree(parse_attr->mod_hdr_actions); |
| 952 | if (err) | 951 | if (err) |
| 953 | return err; | 952 | return err; |
| @@ -1304,14 +1303,13 @@ void mlx5e_tc_encap_flows_add(struct mlx5e_priv *priv, · 350 unmodified lines | |||
| 1304 | struct mlx5e_tc_flow *flow; | 1303 | struct mlx5e_tc_flow *flow; |
| 1305 | int err; | 1304 | int err; |
| 1306 | 1305 | ||
| 1307 | err = mlx5_packet_reformat_alloc(priv->mdev, | 1306 | e->pkt_reformat = mlx5_packet_reformat_alloc(priv->mdev, |
| 1308 | e->reformat_type, | 1307 | e->reformat_type, |
| 1309 | e->encap_size, e->encap_header, | 1308 | e->encap_size, e->encap_header, |
| 1310 | MLX5_FLOW_NAMESPACE_FDB, | 1309 | MLX5_FLOW_NAMESPACE_FDB); |
| 1311 | &e->encap_id); | 1310 | if (IS_ERR(e->pkt_reformat)) { |
| 1312 | if (err) { | 1311 | mlx5_core_warn(priv->mdev, "Failed to offload cached encapsulation header, %lu\n", |
| 1313 | mlx5_core_warn(priv->mdev, "Failed to offload cached encapsulation header, %d\n", | 1312 | PTR_ERR(e->pkt_reformat)); |
| 1314 | err); | ||
| 1315 | return; | 1313 | return; |
| 1316 | } | 1314 | } |
| 1317 | e->flags |= MLX5_ENCAP_ENTRY_VALID; | 1315 | e->flags |= MLX5_ENCAP_ENTRY_VALID; |
| @@ -1326,7 +1324,7 @@ void mlx5e_tc_encap_flows_add(struct mlx5e_priv *priv, · 8 unmodified lines | |||
| 1326 | esw_attr = flow->esw_attr; | 1324 | esw_attr = flow->esw_attr; |
| 1327 | spec = &esw_attr->parse_attr->spec; | 1325 | spec = &esw_attr->parse_attr->spec; |
| 1328 | 1326 | ||
| 1329 | esw_attr->dests[flow->tmp_efi_index].encap_id = e->encap_id; | 1327 | esw_attr->dests[flow->tmp_efi_index].pkt_reformat = e->pkt_reformat; |
| 1330 | esw_attr->dests[flow->tmp_efi_index].flags |= MLX5_ESW_DEST_ENCAP_VALID; | 1328 | esw_attr->dests[flow->tmp_efi_index].flags |= MLX5_ESW_DEST_ENCAP_VALID; |
| 1331 | /* Flow can be associated with multiple encap entries. | 1329 | /* Flow can be associated with multiple encap entries. |
| 1332 | * Before offloading the flow verify that all of them have | 1330 | * Before offloading the flow verify that all of them have |
| @@ -1395,7 +1393,7 @@ void mlx5e_tc_encap_flows_del(struct mlx5e_priv *priv, · 62 unmodified lines | |||
| 1395 | 1393 | ||
| 1396 | /* we know that the encap is valid */ | 1394 | /* we know that the encap is valid */ |
| 1397 | e->flags &= ~MLX5_ENCAP_ENTRY_VALID; | 1395 | e->flags &= ~MLX5_ENCAP_ENTRY_VALID; |
| 1398 | mlx5_packet_reformat_dealloc(priv->mdev, e->encap_id); | 1396 | mlx5_packet_reformat_dealloc(priv->mdev, e->pkt_reformat); |
| 1399 | } | 1397 | } |
| 1400 | 1398 | ||
| 1401 | static struct mlx5_fc *mlx5e_tc_get_counter(struct mlx5e_tc_flow *flow) | 1399 | static struct mlx5_fc *mlx5e_tc_get_counter(struct mlx5e_tc_flow *flow) |
| @@ -1561,7 +1559,7 @@ static void mlx5e_encap_dealloc(struct mlx5e_priv *priv, struct mlx5e_encap_entr · 159 unmodified lines | |||
| 1561 | mlx5e_rep_encap_entry_detach(netdev_priv(e->out_dev), e); | 1559 | mlx5e_rep_encap_entry_detach(netdev_priv(e->out_dev), e); |
| 1562 | 1560 | ||
| 1563 | if (e->flags & MLX5_ENCAP_ENTRY_VALID) | 1561 | if (e->flags & MLX5_ENCAP_ENTRY_VALID) |
| 1564 | mlx5_packet_reformat_dealloc(priv->mdev, e->encap_id); | 1562 | mlx5_packet_reformat_dealloc(priv->mdev, e->pkt_reformat); |
| 1565 | } | 1563 | } |
| 1566 | 1564 | ||
| 1567 | kfree(e->encap_header); | 1565 | kfree(e->encap_header); |
| @@ -3048,7 +3046,7 @@ attach_flow: · 1480 unmodified lines | |||
| 3048 | flow->encaps[out_index].index = out_index; | 3046 | flow->encaps[out_index].index = out_index; |
| 3049 | *encap_dev = e->out_dev; | 3047 | *encap_dev = e->out_dev; |
| 3050 | if (e->flags & MLX5_ENCAP_ENTRY_VALID) { | 3048 | if (e->flags & MLX5_ENCAP_ENTRY_VALID) { |
| 3051 | attr->dests[out_index].encap_id = e->encap_id; | 3049 | attr->dests[out_index].pkt_reformat = e->pkt_reformat; |
| 3052 | attr->dests[out_index].flags |= MLX5_ESW_DEST_ENCAP_VALID; | 3050 | attr->dests[out_index].flags |= MLX5_ESW_DEST_ENCAP_VALID; |
| 3053 | *encap_valid = true; | 3051 | *encap_valid = true; |
| 3054 | } else { | 3052 | } else { |
| @@ -69,7 +69,7 @@ struct vport_ingress { · 68 unmodified lines | |||
| 69 | struct mlx5_flow_group *allow_spoofchk_only_grp; | 69 | struct mlx5_flow_group *allow_spoofchk_only_grp; |
| 70 | struct mlx5_flow_group *allow_untagged_only_grp; | 70 | struct mlx5_flow_group *allow_untagged_only_grp; |
| 71 | struct mlx5_flow_group *drop_grp; | 71 | struct mlx5_flow_group *drop_grp; |
| 72 | int modify_metadata_id; | 72 | struct mlx5_modify_hdr *modify_metadata; |
| 73 | struct mlx5_flow_handle *modify_metadata_rule; | 73 | struct mlx5_flow_handle *modify_metadata_rule; |
| 74 | struct mlx5_flow_handle *allow_rule; | 74 | struct mlx5_flow_handle *allow_rule; |
| 75 | struct mlx5_flow_handle *drop_rule; | 75 | struct mlx5_flow_handle *drop_rule; |
| @@ -385,11 +385,11 @@ struct mlx5_esw_flow_attr { · 309 unmodified lines | |||
| 385 | struct { | 385 | struct { |
| 386 | u32 flags; | 386 | u32 flags; |
| 387 | struct mlx5_eswitch_rep *rep; | 387 | struct mlx5_eswitch_rep *rep; |
| 388 | struct mlx5_pkt_reformat *pkt_reformat; | ||
| 388 | struct mlx5_core_dev *mdev; | 389 | struct mlx5_core_dev *mdev; |
| 389 | u32 encap_id; | ||
| 390 | struct mlx5_termtbl_handle *termtbl; | 390 | struct mlx5_termtbl_handle *termtbl; |
| 391 | } dests[MLX5_MAX_FLOW_FWD_VPORTS]; | 391 | } dests[MLX5_MAX_FLOW_FWD_VPORTS]; |
| 392 | u32 mod_hdr_id; | 392 | struct mlx5_modify_hdr *modify_hdr; |
| 393 | u8 inner_match_level; | 393 | u8 inner_match_level; |
| 394 | u8 outer_match_level; | 394 | u8 outer_match_level; |
| 395 | struct mlx5_fc *counter; | 395 | struct mlx5_fc *counter; |
| @@ -190,10 +190,10 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw, · 189 unmodified lines | |||
| 190 | MLX5_FLOW_DEST_VPORT_VHCA_ID; | 190 | MLX5_FLOW_DEST_VPORT_VHCA_ID; |
| 191 | if (attr->dests[j].flags & MLX5_ESW_DEST_ENCAP) { | 191 | if (attr->dests[j].flags & MLX5_ESW_DEST_ENCAP) { |
| 192 | flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; | 192 | flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_PACKET_REFORMAT; |
| 193 | flow_act.reformat_id = attr->dests[j].encap_id; | 193 | flow_act.pkt_reformat = attr->dests[j].pkt_reformat; |
| 194 | dest[i].vport.flags |= MLX5_FLOW_DEST_VPORT_REFORMAT_ID; | 194 | dest[i].vport.flags |= MLX5_FLOW_DEST_VPORT_REFORMAT_ID; |
| 195 | dest[i].vport.reformat_id = | 195 | dest[i].vport.pkt_reformat = |
| 196 | attr->dests[j].encap_id; | 196 | attr->dests[j].pkt_reformat; |
| 197 | } | 197 | } |
| 198 | i++; | 198 | i++; |
| 199 | } | 199 | } |
| @@ -213,7 +213,7 @@ mlx5_eswitch_add_offloaded_rule(struct mlx5_eswitch *esw, · 13 unmodified lines | |||
| 213 | spec->match_criteria_enable |= MLX5_MATCH_INNER_HEADERS; | 213 | spec->match_criteria_enable |= MLX5_MATCH_INNER_HEADERS; |
| 214 | 214 | ||
| 215 | if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) | 215 | if (flow_act.action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR) |
| 216 | flow_act.modify_id = attr->mod_hdr_id; | 216 | flow_act.modify_hdr = attr->modify_hdr; |
| 217 | 217 | ||
| 218 | fdb = esw_get_prio_table(esw, attr->chain, attr->prio, !!split); | 218 | fdb = esw_get_prio_table(esw, attr->chain, attr->prio, !!split); |
| 219 | if (IS_ERR(fdb)) { | 219 | if (IS_ERR(fdb)) { |
| @@ -276,7 +276,7 @@ mlx5_eswitch_add_fwd_rule(struct mlx5_eswitch *esw, · 56 unmodified lines | |||
| 276 | dest[i].vport.flags |= MLX5_FLOW_DEST_VPORT_VHCA_ID; | 276 | dest[i].vport.flags |= MLX5_FLOW_DEST_VPORT_VHCA_ID; |
| 277 | if (attr->dests[i].flags & MLX5_ESW_DEST_ENCAP) { | 277 | if (attr->dests[i].flags & MLX5_ESW_DEST_ENCAP) { |
| 278 | dest[i].vport.flags |= MLX5_FLOW_DEST_VPORT_REFORMAT_ID; | 278 | dest[i].vport.flags |= MLX5_FLOW_DEST_VPORT_REFORMAT_ID; |
| 279 | dest[i].vport.reformat_id = attr->dests[i].encap_id; | 279 | dest[i].vport.pkt_reformat = attr->dests[i].pkt_reformat; |
| 280 | } | 280 | } |
| 281 | } | 281 | } |
| 282 | dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE; | 282 | dest[i].type = MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE; |
| @@ -1734,7 +1734,7 @@ static int esw_vport_ingress_prio_tag_config(struct mlx5_eswitch *esw, · 1451 unmodified lines | |||
| 1734 | 1734 | ||
| 1735 | if (vport->ingress.modify_metadata_rule) { | 1735 | if (vport->ingress.modify_metadata_rule) { |
| 1736 | flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; | 1736 | flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; |
| 1737 | flow_act.modify_id = vport->ingress.modify_metadata_id; | 1737 | flow_act.modify_hdr = vport->ingress.modify_metadata; |
| 1738 | } | 1738 | } |
| 1739 | 1739 | ||
| 1740 | vport->ingress.allow_rule = | 1740 | vport->ingress.allow_rule = |
| @@ -1770,9 +1770,11 @@ static int esw_vport_add_ingress_acl_modify_metadata(struct mlx5_eswitch *esw, · 29 unmodified lines | |||
| 1770 | MLX5_SET(set_action_in, action, data, | 1770 | MLX5_SET(set_action_in, action, data, |
| 1771 | mlx5_eswitch_get_vport_metadata_for_match(esw, vport->vport)); | 1771 | mlx5_eswitch_get_vport_metadata_for_match(esw, vport->vport)); |
| 1772 | 1772 | ||
| 1773 | err = mlx5_modify_header_alloc(esw->dev, MLX5_FLOW_NAMESPACE_ESW_INGRESS, | 1773 | vport->ingress.modify_metadata = |
| 1774 | 1, action, &vport->ingress.modify_metadata_id); | 1774 | mlx5_modify_header_alloc(esw->dev, MLX5_FLOW_NAMESPACE_ESW_INGRESS, |
| 1775 | if (err) { | 1775 | 1, action); |
| 1776 | if (IS_ERR(vport->ingress.modify_metadata)) { | ||
| 1777 | err = PTR_ERR(vport->ingress.modify_metadata); | ||
| 1776 | esw_warn(esw->dev, | 1778 | esw_warn(esw->dev, |
| 1777 | "failed to alloc modify header for vport %d ingress acl (%d)\n", | 1779 | "failed to alloc modify header for vport %d ingress acl (%d)\n", |
| 1778 | vport->vport, err); | 1780 | vport->vport, err); |
| @@ -1780,7 +1782,7 @@ static int esw_vport_add_ingress_acl_modify_metadata(struct mlx5_eswitch *esw, · 1 unmodified line | |||
| 1780 | } | 1782 | } |
| 1781 | 1783 | ||
| 1782 | flow_act.action = MLX5_FLOW_CONTEXT_ACTION_MOD_HDR | MLX5_FLOW_CONTEXT_ACTION_ALLOW; | 1784 | flow_act.action = MLX5_FLOW_CONTEXT_ACTION_MOD_HDR | MLX5_FLOW_CONTEXT_ACTION_ALLOW; |
| 1783 | flow_act.modify_id = vport->ingress.modify_metadata_id; | 1785 | flow_act.modify_hdr = vport->ingress.modify_metadata; |
| 1784 | vport->ingress.modify_metadata_rule = mlx5_add_flow_rules(vport->ingress.acl, | 1786 | vport->ingress.modify_metadata_rule = mlx5_add_flow_rules(vport->ingress.acl, |
| 1785 | &spec, &flow_act, NULL, 0); | 1787 | &spec, &flow_act, NULL, 0); |
| 1786 | if (IS_ERR(vport->ingress.modify_metadata_rule)) { | 1788 | if (IS_ERR(vport->ingress.modify_metadata_rule)) { |
| @@ -1794,7 +1796,7 @@ static int esw_vport_add_ingress_acl_modify_metadata(struct mlx5_eswitch *esw, · 7 unmodified lines | |||
| 1794 | 1796 | ||
| 1795 | out: | 1797 | out: |
| 1796 | if (err) | 1798 | if (err) |
| 1797 | mlx5_modify_header_dealloc(esw->dev, vport->ingress.modify_metadata_id); | 1799 | mlx5_modify_header_dealloc(esw->dev, vport->ingress.modify_metadata); |
| 1798 | return err; | 1800 | return err; |
| 1799 | } | 1801 | } |
| 1800 | 1802 | ||
| @@ -1803,7 +1805,7 @@ void esw_vport_del_ingress_acl_modify_metadata(struct mlx5_eswitch *esw, · 2 unmodified lines | |||
| 1803 | { | 1805 | { |
| 1804 | if (vport->ingress.modify_metadata_rule) { | 1806 | if (vport->ingress.modify_metadata_rule) { |
| 1805 | mlx5_del_flow_rules(vport->ingress.modify_metadata_rule); | 1807 | mlx5_del_flow_rules(vport->ingress.modify_metadata_rule); |
| 1806 | mlx5_modify_header_dealloc(esw->dev, vport->ingress.modify_metadata_id); | 1808 | mlx5_modify_header_dealloc(esw->dev, vport->ingress.modify_metadata); |
| 1807 | 1809 | ||
| 1808 | vport->ingress.modify_metadata_rule = NULL; | 1810 | vport->ingress.modify_metadata_rule = NULL; |
| 1809 | } | 1811 | } |
| @@ -107,6 +107,34 @@ static int mlx5_cmd_stub_delete_fte(struct mlx5_flow_root_namespace *ns, · 106 unmodified lines | |||
| 107 | return 0; | 107 | return 0; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | static int mlx5_cmd_stub_packet_reformat_alloc(struct mlx5_flow_root_namespace *ns, | ||
| 111 | int reformat_type, | ||
| 112 | size_t size, | ||
| 113 | void *reformat_data, | ||
| 114 | enum mlx5_flow_namespace_type namespace, | ||
| 115 | struct mlx5_pkt_reformat *pkt_reformat) | ||
| 116 | { | ||
| 117 | return 0; | ||
| 118 | } | ||
| 119 | |||
| 120 | static void mlx5_cmd_stub_packet_reformat_dealloc(struct mlx5_flow_root_namespace *ns, | ||
| 121 | struct mlx5_pkt_reformat *pkt_reformat) | ||
| 122 | { | ||
| 123 | } | ||
| 124 | |||
| 125 | static int mlx5_cmd_stub_modify_header_alloc(struct mlx5_flow_root_namespace *ns, | ||
| 126 | u8 namespace, u8 num_actions, | ||
| 127 | void *modify_actions, | ||
| 128 | struct mlx5_modify_hdr *modify_hdr) | ||
| 129 | { | ||
| 130 | return 0; | ||
| 131 | } | ||
| 132 | |||
| 133 | static void mlx5_cmd_stub_modify_header_dealloc(struct mlx5_flow_root_namespace *ns, | ||
| 134 | struct mlx5_modify_hdr *modify_hdr) | ||
| 135 | { | ||
| 136 | } | ||
| 137 | |||
| 110 | static int mlx5_cmd_update_root_ft(struct mlx5_flow_root_namespace *ns, | 138 | static int mlx5_cmd_update_root_ft(struct mlx5_flow_root_namespace *ns, |
| 111 | struct mlx5_flow_table *ft, u32 underlay_qpn, | 139 | struct mlx5_flow_table *ft, u32 underlay_qpn, |
| 112 | bool disconnect) | 140 | bool disconnect) |
| @@ -412,11 +440,13 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, · 299 unmodified lines | |||
| 412 | } else { | 440 | } else { |
| 413 | MLX5_SET(flow_context, in_flow_context, action, | 441 | MLX5_SET(flow_context, in_flow_context, action, |
| 414 | fte->action.action); | 442 | fte->action.action); |
| 415 | MLX5_SET(flow_context, in_flow_context, packet_reformat_id, | 443 | if (fte->action.pkt_reformat) |
| 416 | fte->action.reformat_id); | 444 | MLX5_SET(flow_context, in_flow_context, packet_reformat_id, |
| 445 | fte->action.pkt_reformat->id); | ||
| 417 | } | 446 | } |
| 418 | MLX5_SET(flow_context, in_flow_context, modify_header_id, | 447 | if (fte->action.modify_hdr) |
| 419 | fte->action.modify_id); | 448 | MLX5_SET(flow_context, in_flow_context, modify_header_id, |
| 449 | fte->action.modify_hdr->id); | ||
| 420 | 450 | ||
| 421 | vlan = MLX5_ADDR_OF(flow_context, in_flow_context, push_vlan); | 451 | vlan = MLX5_ADDR_OF(flow_context, in_flow_context, push_vlan); |
| 422 | 452 | ||
| @@ -468,7 +498,7 @@ static int mlx5_cmd_set_fte(struct mlx5_core_dev *dev, · 45 unmodified lines | |||
| 468 | MLX5_FLOW_DEST_VPORT_REFORMAT_ID)); | 498 | MLX5_FLOW_DEST_VPORT_REFORMAT_ID)); |
| 469 | MLX5_SET(extended_dest_format, in_dests, | 499 | MLX5_SET(extended_dest_format, in_dests, |
| 470 | packet_reformat_id, | 500 | packet_reformat_id, |
| 471 | dst->dest_attr.vport.reformat_id); | 501 | dst->dest_attr.vport.pkt_reformat->id); |
| 472 | } | 502 | } |
| 473 | break; | 503 | break; |
| 474 | default: | 504 | default: |
| @@ -643,14 +673,15 @@ int mlx5_cmd_fc_bulk_query(struct mlx5_core_dev *dev, u32 base_id, int bulk_len, · 168 unmodified lines | |||
| 643 | return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen); | 673 | return mlx5_cmd_exec(dev, in, sizeof(in), out, outlen); |
| 644 | } | 674 | } |
| 645 | 675 | ||
| 646 | int mlx5_packet_reformat_alloc(struct mlx5_core_dev *dev, | 676 | static int mlx5_cmd_packet_reformat_alloc(struct mlx5_flow_root_namespace *ns, |
| 647 | int reformat_type, | 677 | int reformat_type, |
| 648 | size_t size, | 678 | size_t size, |
| 649 | void *reformat_data, | 679 | void *reformat_data, |
| 650 | enum mlx5_flow_namespace_type namespace, | 680 | enum mlx5_flow_namespace_type namespace, |
| 651 | u32 *packet_reformat_id) | 681 | struct mlx5_pkt_reformat *pkt_reformat) |
| 652 | { | 682 | { |
| 653 | u32 out[MLX5_ST_SZ_DW(alloc_packet_reformat_context_out)]; | 683 | u32 out[MLX5_ST_SZ_DW(alloc_packet_reformat_context_out)]; |
| 684 | struct mlx5_core_dev *dev = ns->dev; | ||
| 654 | void *packet_reformat_context_in; | 685 | void *packet_reformat_context_in; |
| 655 | int max_encap_size; | 686 | int max_encap_size; |
| 656 | void *reformat; | 687 | void *reformat; |
| @@ -693,35 +724,36 @@ int mlx5_packet_reformat_alloc(struct mlx5_core_dev *dev, · 36 unmodified lines | |||
| 693 | memset(out, 0, sizeof(out)); | 724 | memset(out, 0, sizeof(out)); |
| 694 | err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); | 725 | err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); |
| 695 | 726 | ||
| 696 | *packet_reformat_id = MLX5_GET(alloc_packet_reformat_context_out, | 727 | pkt_reformat->id = MLX5_GET(alloc_packet_reformat_context_out, |
| 697 | out, packet_reformat_id); | 728 | out, packet_reformat_id); |
| 698 | kfree(in); | 729 | kfree(in); |
| 699 | return err; | 730 | return err; |
| 700 | } | 731 | } |
| 701 | EXPORT_SYMBOL(mlx5_packet_reformat_alloc); | ||
| 702 | 732 | ||
| 703 | void mlx5_packet_reformat_dealloc(struct mlx5_core_dev *dev, | 733 | static void mlx5_cmd_packet_reformat_dealloc(struct mlx5_flow_root_namespace *ns, |
| 704 | u32 packet_reformat_id) | 734 | struct mlx5_pkt_reformat *pkt_reformat) |
| 705 | { | 735 | { |
| 706 | u32 in[MLX5_ST_SZ_DW(dealloc_packet_reformat_context_in)]; | 736 | u32 in[MLX5_ST_SZ_DW(dealloc_packet_reformat_context_in)]; |
| 707 | u32 out[MLX5_ST_SZ_DW(dealloc_packet_reformat_context_out)]; | 737 | u32 out[MLX5_ST_SZ_DW(dealloc_packet_reformat_context_out)]; |
| 738 | struct mlx5_core_dev *dev = ns->dev; | ||
| 708 | 739 | ||
| 709 | memset(in, 0, sizeof(in)); | 740 | memset(in, 0, sizeof(in)); |
| 710 | MLX5_SET(dealloc_packet_reformat_context_in, in, opcode, | 741 | MLX5_SET(dealloc_packet_reformat_context_in, in, opcode, |
| 711 | MLX5_CMD_OP_DEALLOC_PACKET_REFORMAT_CONTEXT); | 742 | MLX5_CMD_OP_DEALLOC_PACKET_REFORMAT_CONTEXT); |
| 712 | MLX5_SET(dealloc_packet_reformat_context_in, in, packet_reformat_id, | 743 | MLX5_SET(dealloc_packet_reformat_context_in, in, packet_reformat_id, |
| 713 | packet_reformat_id); | 744 | pkt_reformat->id); |
| 714 | 745 | ||
| 715 | mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); | 746 | mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); |
| 716 | } | 747 | } |
| 717 | EXPORT_SYMBOL(mlx5_packet_reformat_dealloc); | ||
| 718 | 748 | ||
| 719 | int mlx5_modify_header_alloc(struct mlx5_core_dev *dev, | 749 | static int mlx5_cmd_modify_header_alloc(struct mlx5_flow_root_namespace *ns, |
| 720 | u8 namespace, u8 num_actions, | 750 | u8 namespace, u8 num_actions, |
| 721 | void *modify_actions, u32 *modify_header_id) | 751 | void *modify_actions, |
| 752 | struct mlx5_modify_hdr *modify_hdr) | ||
| 722 | { | 753 | { |
| 723 | u32 out[MLX5_ST_SZ_DW(alloc_modify_header_context_out)]; | 754 | u32 out[MLX5_ST_SZ_DW(alloc_modify_header_context_out)]; |
| 724 | int max_actions, actions_size, inlen, err; | 755 | int max_actions, actions_size, inlen, err; |
| 756 | struct mlx5_core_dev *dev = ns->dev; | ||
| 725 | void *actions_in; | 757 | void *actions_in; |
| 726 | u8 table_type; | 758 | u8 table_type; |
| 727 | u32 *in; | 759 | u32 *in; |
| @@ -772,26 +804,26 @@ int mlx5_modify_header_alloc(struct mlx5_core_dev *dev, · 44 unmodified lines | |||
| 772 | memset(out, 0, sizeof(out)); | 804 | memset(out, 0, sizeof(out)); |
| 773 | err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); | 805 | err = mlx5_cmd_exec(dev, in, inlen, out, sizeof(out)); |
| 774 | 806 | ||
| 775 | *modify_header_id = MLX5_GET(alloc_modify_header_context_out, out, modify_header_id); | 807 | modify_hdr->id = MLX5_GET(alloc_modify_header_context_out, out, modify_header_id); |
| 776 | kfree(in); | 808 | kfree(in); |
| 777 | return err; | 809 | return err; |
| 778 | } | 810 | } |
| 779 | EXPORT_SYMBOL(mlx5_modify_header_alloc); | ||
| 780 | 811 | ||
| 781 | void mlx5_modify_header_dealloc(struct mlx5_core_dev *dev, u32 modify_header_id) | 812 | static void mlx5_cmd_modify_header_dealloc(struct mlx5_flow_root_namespace *ns, |
| 813 | struct mlx5_modify_hdr *modify_hdr) | ||
| 782 | { | 814 | { |
| 783 | u32 in[MLX5_ST_SZ_DW(dealloc_modify_header_context_in)]; | 815 | u32 in[MLX5_ST_SZ_DW(dealloc_modify_header_context_in)]; |
| 784 | u32 out[MLX5_ST_SZ_DW(dealloc_modify_header_context_out)]; | 816 | u32 out[MLX5_ST_SZ_DW(dealloc_modify_header_context_out)]; |
| 817 | struct mlx5_core_dev *dev = ns->dev; | ||
| 785 | 818 | ||
| 786 | memset(in, 0, sizeof(in)); | 819 | memset(in, 0, sizeof(in)); |
| 787 | MLX5_SET(dealloc_modify_header_context_in, in, opcode, | 820 | MLX5_SET(dealloc_modify_header_context_in, in, opcode, |
| 788 | MLX5_CMD_OP_DEALLOC_MODIFY_HEADER_CONTEXT); | 821 | MLX5_CMD_OP_DEALLOC_MODIFY_HEADER_CONTEXT); |
| 789 | MLX5_SET(dealloc_modify_header_context_in, in, modify_header_id, | 822 | MLX5_SET(dealloc_modify_header_context_in, in, modify_header_id, |
| 790 | modify_header_id); | 823 | modify_hdr->id); |
| 791 | 824 | ||
| 792 | mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); | 825 | mlx5_cmd_exec(dev, in, sizeof(in), out, sizeof(out)); |
| 793 | } | 826 | } |
| 794 | EXPORT_SYMBOL(mlx5_modify_header_dealloc); | ||
| 795 | 827 | ||
| 796 | static const struct mlx5_flow_cmds mlx5_flow_cmds = { | 828 | static const struct mlx5_flow_cmds mlx5_flow_cmds = { |
| 797 | .create_flow_table = mlx5_cmd_create_flow_table, | 829 | .create_flow_table = mlx5_cmd_create_flow_table, |
| @@ -803,6 +835,10 @@ static const struct mlx5_flow_cmds mlx5_flow_cmds = { · 5 unmodified lines | |||
| 803 | .update_fte = mlx5_cmd_update_fte, | 835 | .update_fte = mlx5_cmd_update_fte, |
| 804 | .delete_fte = mlx5_cmd_delete_fte, | 836 | .delete_fte = mlx5_cmd_delete_fte, |
| 805 | .update_root_ft = mlx5_cmd_update_root_ft, | 837 | .update_root_ft = mlx5_cmd_update_root_ft, |
| 838 | .packet_reformat_alloc = mlx5_cmd_packet_reformat_alloc, | ||
| 839 | .packet_reformat_dealloc = mlx5_cmd_packet_reformat_dealloc, | ||
| 840 | .modify_header_alloc = mlx5_cmd_modify_header_alloc, | ||
| 841 | .modify_header_dealloc = mlx5_cmd_modify_header_dealloc | ||
| 806 | }; | 842 | }; |
| 807 | 843 | ||
| 808 | static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = { | 844 | static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = { |
| @@ -815,6 +851,10 @@ static const struct mlx5_flow_cmds mlx5_flow_cmd_stubs = { · 6 unmodified lines | |||
| 815 | .update_fte = mlx5_cmd_stub_update_fte, | 851 | .update_fte = mlx5_cmd_stub_update_fte, |
| 816 | .delete_fte = mlx5_cmd_stub_delete_fte, | 852 | .delete_fte = mlx5_cmd_stub_delete_fte, |
| 817 | .update_root_ft = mlx5_cmd_stub_update_root_ft, | 853 | .update_root_ft = mlx5_cmd_stub_update_root_ft, |
| 854 | .packet_reformat_alloc = mlx5_cmd_stub_packet_reformat_alloc, | ||
| 855 | .packet_reformat_dealloc = mlx5_cmd_stub_packet_reformat_dealloc, | ||
| 856 | .modify_header_alloc = mlx5_cmd_stub_modify_header_alloc, | ||
| 857 | .modify_header_dealloc = mlx5_cmd_stub_modify_header_dealloc | ||
| 818 | }; | 858 | }; |
| 819 | 859 | ||
| 820 | static const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void) | 860 | static const struct mlx5_flow_cmds *mlx5_fs_cmd_get_fw_cmds(void) |
| @@ -75,6 +75,24 @@ struct mlx5_flow_cmds { · 74 unmodified lines | |||
| 75 | struct mlx5_flow_table *ft, | 75 | struct mlx5_flow_table *ft, |
| 76 | u32 underlay_qpn, | 76 | u32 underlay_qpn, |
| 77 | bool disconnect); | 77 | bool disconnect); |
| 78 | |||
| 79 | int (*packet_reformat_alloc)(struct mlx5_flow_root_namespace *ns, | ||
| 80 | int reformat_type, | ||
| 81 | size_t size, | ||
| 82 | void *reformat_data, | ||
| 83 | enum mlx5_flow_namespace_type namespace, | ||
| 84 | struct mlx5_pkt_reformat *pkt_reformat); | ||
| 85 | |||
| 86 | void (*packet_reformat_dealloc)(struct mlx5_flow_root_namespace *ns, | ||
| 87 | struct mlx5_pkt_reformat *pkt_reformat); | ||
| 88 | |||
| 89 | int (*modify_header_alloc)(struct mlx5_flow_root_namespace *ns, | ||
| 90 | u8 namespace, u8 num_actions, | ||
| 91 | void *modify_actions, | ||
| 92 | struct mlx5_modify_hdr *modify_hdr); | ||
| 93 | |||
| 94 | void (*modify_header_dealloc)(struct mlx5_flow_root_namespace *ns, | ||
| 95 | struct mlx5_modify_hdr *modify_hdr); | ||
| 78 | }; | 96 | }; |
| 79 | 97 | ||
| 80 | int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id); | 98 | int mlx5_cmd_fc_alloc(struct mlx5_core_dev *dev, u32 *id); |
| @@ -1415,7 +1415,8 @@ static bool mlx5_flow_dests_cmp(struct mlx5_flow_destination *d1, · 1414 unmodified lines | |||
| 1415 | ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_VHCA_ID) ? | 1415 | ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_VHCA_ID) ? |
| 1416 | (d1->vport.vhca_id == d2->vport.vhca_id) : true) && | 1416 | (d1->vport.vhca_id == d2->vport.vhca_id) : true) && |
| 1417 | ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID) ? | 1417 | ((d1->vport.flags & MLX5_FLOW_DEST_VPORT_REFORMAT_ID) ? |
| 1418 | (d1->vport.reformat_id == d2->vport.reformat_id) : true)) || | 1418 | (d1->vport.pkt_reformat->id == |
| 1419 | d2->vport.pkt_reformat->id) : true)) || | ||
| 1419 | (d1->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE && | 1420 | (d1->type == MLX5_FLOW_DESTINATION_TYPE_FLOW_TABLE && |
| 1420 | d1->ft == d2->ft) || | 1421 | d1->ft == d2->ft) || |
| 1421 | (d1->type == MLX5_FLOW_DESTINATION_TYPE_TIR && | 1422 | (d1->type == MLX5_FLOW_DESTINATION_TYPE_TIR && |
| @@ -2888,3 +2889,105 @@ out: · 1466 unmodified lines | |||
| 2888 | return err; | 2889 | return err; |
| 2889 | } | 2890 | } |
| 2890 | EXPORT_SYMBOL(mlx5_fs_remove_rx_underlay_qpn); | 2891 | EXPORT_SYMBOL(mlx5_fs_remove_rx_underlay_qpn); |
| 2892 | |||
| 2893 | static struct mlx5_flow_root_namespace | ||
| 2894 | *get_root_namespace(struct mlx5_core_dev *dev, enum mlx5_flow_namespace_type ns_type) | ||
| 2895 | { | ||
| 2896 | struct mlx5_flow_namespace *ns; | ||
| 2897 | |||
| 2898 | if (ns_type == MLX5_FLOW_NAMESPACE_ESW_EGRESS || | ||
| 2899 | ns_type == MLX5_FLOW_NAMESPACE_ESW_INGRESS) | ||
| 2900 | ns = mlx5_get_flow_vport_acl_namespace(dev, ns_type, 0); | ||
| 2901 | else | ||
| 2902 | ns = mlx5_get_flow_namespace(dev, ns_type); | ||
| 2903 | if (!ns) | ||
| 2904 | return NULL; | ||
| 2905 | |||
| 2906 | return find_root(&ns->node); | ||
| 2907 | } | ||
| 2908 | |||
| 2909 | struct mlx5_modify_hdr *mlx5_modify_header_alloc(struct mlx5_core_dev *dev, | ||
| 2910 | u8 ns_type, u8 num_actions, | ||
| 2911 | void *modify_actions) | ||
| 2912 | { | ||
| 2913 | struct mlx5_flow_root_namespace *root; | ||
| 2914 | struct mlx5_modify_hdr *modify_hdr; | ||
| 2915 | int err; | ||
| 2916 | |||
| 2917 | root = get_root_namespace(dev, ns_type); | ||
| 2918 | if (!root) | ||
| 2919 | return ERR_PTR(-EOPNOTSUPP); | ||
| 2920 | |||
| 2921 | modify_hdr = kzalloc(sizeof(*modify_hdr), GFP_KERNEL); | ||
| 2922 | if (!modify_hdr) | ||
| 2923 | return ERR_PTR(-ENOMEM); | ||
| 2924 | |||
| 2925 | modify_hdr->ns_type = ns_type; | ||
| 2926 | err = root->cmds->modify_header_alloc(root, ns_type, num_actions, | ||
| 2927 | modify_actions, modify_hdr); | ||
| 2928 | if (err) { | ||
| 2929 | kfree(modify_hdr); | ||
| 2930 | return ERR_PTR(err); | ||
| 2931 | } | ||
| 2932 | |||
| 2933 | return modify_hdr; | ||
| 2934 | } | ||
| 2935 | EXPORT_SYMBOL(mlx5_modify_header_alloc); | ||
| 2936 | |||
| 2937 | void mlx5_modify_header_dealloc(struct mlx5_core_dev *dev, | ||
| 2938 | struct mlx5_modify_hdr *modify_hdr) | ||
| 2939 | { | ||
| 2940 | struct mlx5_flow_root_namespace *root; | ||
| 2941 | |||
| 2942 | root = get_root_namespace(dev, modify_hdr->ns_type); | ||
| 2943 | if (WARN_ON(!root)) | ||
| 2944 | return; | ||
| 2945 | root->cmds->modify_header_dealloc(root, modify_hdr); | ||
| 2946 | kfree(modify_hdr); | ||
| 2947 | } | ||
| 2948 | EXPORT_SYMBOL(mlx5_modify_header_dealloc); | ||
| 2949 | |||
| 2950 | struct mlx5_pkt_reformat *mlx5_packet_reformat_alloc(struct mlx5_core_dev *dev, | ||
| 2951 | int reformat_type, | ||
| 2952 | size_t size, | ||
| 2953 | void *reformat_data, | ||
| 2954 | enum mlx5_flow_namespace_type ns_type) | ||
| 2955 | { | ||
| 2956 | struct mlx5_pkt_reformat *pkt_reformat; | ||
| 2957 | struct mlx5_flow_root_namespace *root; | ||
| 2958 | int err; | ||
| 2959 | |||
| 2960 | root = get_root_namespace(dev, ns_type); | ||
| 2961 | if (!root) | ||
| 2962 | return ERR_PTR(-EOPNOTSUPP); | ||
| 2963 | |||
| 2964 | pkt_reformat = kzalloc(sizeof(*pkt_reformat), GFP_KERNEL); | ||
| 2965 | if (!pkt_reformat) | ||
| 2966 | return ERR_PTR(-ENOMEM); | ||
| 2967 | |||
| 2968 | pkt_reformat->ns_type = ns_type; | ||
| 2969 | pkt_reformat->reformat_type = reformat_type; | ||
| 2970 | err = root->cmds->packet_reformat_alloc(root, reformat_type, size, | ||
| 2971 | reformat_data, ns_type, | ||
| 2972 | pkt_reformat); | ||
| 2973 | if (err) { | ||
| 2974 | kfree(pkt_reformat); | ||
| 2975 | return ERR_PTR(err); | ||
| 2976 | } | ||
| 2977 | |||
| 2978 | return pkt_reformat; | ||
| 2979 | } | ||
| 2980 | EXPORT_SYMBOL(mlx5_packet_reformat_alloc); | ||
| 2981 | |||
| 2982 | void mlx5_packet_reformat_dealloc(struct mlx5_core_dev *dev, | ||
| 2983 | struct mlx5_pkt_reformat *pkt_reformat) | ||
| 2984 | { | ||
| 2985 | struct mlx5_flow_root_namespace *root; | ||
| 2986 | |||
| 2987 | root = get_root_namespace(dev, pkt_reformat->ns_type); | ||
| 2988 | if (WARN_ON(!root)) | ||
| 2989 | return; | ||
| 2990 | root->cmds->packet_reformat_dealloc(root, pkt_reformat); | ||
| 2991 | kfree(pkt_reformat); | ||
| 2992 | } | ||
| 2993 | EXPORT_SYMBOL(mlx5_packet_reformat_dealloc); | ||
| @@ -38,6 +38,17 @@ · 37 unmodified lines | |||
| 38 | #include <linux/rhashtable.h> | 38 | #include <linux/rhashtable.h> |
| 39 | #include <linux/llist.h> | 39 | #include <linux/llist.h> |
| 40 | 40 | ||
| 41 | struct mlx5_modify_hdr { | ||
| 42 | enum mlx5_flow_namespace_type ns_type; | ||
| 43 | u32 id; | ||
| 44 | }; | ||
| 45 | |||
| 46 | struct mlx5_pkt_reformat { | ||
| 47 | enum mlx5_flow_namespace_type ns_type; | ||
| 48 | int reformat_type; /* from mlx5_ifc */ | ||
| 49 | u32 id; | ||
| 50 | }; | ||
| 51 | |||
| 41 | /* FS_TYPE_PRIO_CHAINS is a PRIO that will have namespaces only, | 52 | /* FS_TYPE_PRIO_CHAINS is a PRIO that will have namespaces only, |
| 42 | * and those are in parallel to one another when going over them to connect | 53 | * and those are in parallel to one another when going over them to connect |
| 43 | * a new flow table. Meaning the last flow table in a TYPE_PRIO prio in one | 54 | * a new flow table. Meaning the last flow table in a TYPE_PRIO prio in one |
| @@ -84,6 +84,8 @@ enum { · 83 unmodified lines | |||
| 84 | FDB_SLOW_PATH, | 84 | FDB_SLOW_PATH, |
| 85 | }; | 85 | }; |
| 86 | 86 | ||
| 87 | struct mlx5_pkt_reformat; | ||
| 88 | struct mlx5_modify_hdr; | ||
| 87 | struct mlx5_flow_table; | 89 | struct mlx5_flow_table; |
| 88 | struct mlx5_flow_group; | 90 | struct mlx5_flow_group; |
| 89 | struct mlx5_flow_namespace; | 91 | struct mlx5_flow_namespace; |
| @@ -121,7 +123,7 @@ struct mlx5_flow_destination { · 31 unmodified lines | |||
| 121 | struct { | 123 | struct { |
| 122 | u16 num; | 124 | u16 num; |
| 123 | u16 vhca_id; | 125 | u16 vhca_id; |
| 124 | u32 reformat_id; | 126 | struct mlx5_pkt_reformat *pkt_reformat; |
| 125 | u8 flags; | 127 | u8 flags; |
| 126 | } vport; | 128 | } vport; |
| 127 | }; | 129 | }; |
| @@ -195,8 +197,8 @@ enum { · 67 unmodified lines | |||
| 195 | 197 | ||
| 196 | struct mlx5_flow_act { | 198 | struct mlx5_flow_act { |
| 197 | u32 action; | 199 | u32 action; |
| 198 | u32 reformat_id; | 200 | struct mlx5_modify_hdr *modify_hdr; |
| 199 | u32 modify_id; | 201 | struct mlx5_pkt_reformat *pkt_reformat; |
| 200 | uintptr_t esp_id; | 202 | uintptr_t esp_id; |
| 201 | u32 flags; | 203 | u32 flags; |
| 202 | struct mlx5_fs_vlan vlan[MLX5_FS_VLAN_DEPTH]; | 204 | struct mlx5_fs_vlan vlan[MLX5_FS_VLAN_DEPTH]; |
| @@ -205,8 +207,6 @@ struct mlx5_flow_act { · 2 unmodified lines | |||
| 205 | 207 | ||
| 206 | #define MLX5_DECLARE_FLOW_ACT(name) \ | 208 | #define MLX5_DECLARE_FLOW_ACT(name) \ |
| 207 | struct mlx5_flow_act name = { .action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,\ | 209 | struct mlx5_flow_act name = { .action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST,\ |
| 208 | .reformat_id = 0, \ | ||
| 209 | .modify_id = 0, \ | ||
| 210 | .flags = 0, } | 210 | .flags = 0, } |
| 211 | 211 | ||
| 212 | /* Single destination per rule. | 212 | /* Single destination per rule. |
| @@ -236,19 +236,18 @@ u32 mlx5_fc_id(struct mlx5_fc *counter); · 23 unmodified lines | |||
| 236 | int mlx5_fs_add_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn); | 236 | int mlx5_fs_add_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn); |
| 237 | int mlx5_fs_remove_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn); | 237 | int mlx5_fs_remove_rx_underlay_qpn(struct mlx5_core_dev *dev, u32 underlay_qpn); |
| 238 | 238 | ||
| 239 | int mlx5_modify_header_alloc(struct mlx5_core_dev *dev, | 239 | struct mlx5_modify_hdr *mlx5_modify_header_alloc(struct mlx5_core_dev *dev, |
| 240 | u8 namespace, u8 num_actions, | 240 | u8 ns_type, u8 num_actions, |
| 241 | void *modify_actions, u32 *modify_header_id); | 241 | void *modify_actions); |
| 242 | void mlx5_modify_header_dealloc(struct mlx5_core_dev *dev, | 242 | void mlx5_modify_header_dealloc(struct mlx5_core_dev *dev, |
| 243 | u32 modify_header_id); | 243 | struct mlx5_modify_hdr *modify_hdr); |
| 244 | 244 | ||
| 245 | int mlx5_packet_reformat_alloc(struct mlx5_core_dev *dev, | 245 | struct mlx5_pkt_reformat *mlx5_packet_reformat_alloc(struct mlx5_core_dev *dev, |
| 246 | int reformat_type, | 246 | int reformat_type, |
| 247 | size_t size, | 247 | size_t size, |
| 248 | void *reformat_data, | 248 | void *reformat_data, |
| 249 | enum mlx5_flow_namespace_type namespace, | 249 | enum mlx5_flow_namespace_type ns_type); |
| 250 | u32 *packet_reformat_id); | ||
| 251 | void mlx5_packet_reformat_dealloc(struct mlx5_core_dev *dev, | 250 | void mlx5_packet_reformat_dealloc(struct mlx5_core_dev *dev, |
| 252 | u32 packet_reformat_id); | 251 | struct mlx5_pkt_reformat *reformat); |
| 253 | 252 | ||
| 254 | #endif | 253 | #endif |