* Get a drop flow rule resources instance. * * @param priv * Pointer to private structure. * * @return * Pointer to drop flow resources on success, NULL otherwise and rte_errno * is set. */
| 950 | * is set. |
| 951 | */ |
| 952 | static struct mlx4_drop * |
| 953 | mlx4_drop_get(struct mlx4_priv *priv) |
| 954 | { |
| 955 | struct mlx4_drop *drop = priv->drop; |
| 956 | |
| 957 | if (drop) { |
| 958 | MLX4_ASSERT(drop->refcnt); |
| 959 | MLX4_ASSERT(drop->priv == priv); |
| 960 | ++drop->refcnt; |
| 961 | return drop; |
| 962 | } |
| 963 | drop = rte_malloc(__func__, sizeof(*drop), 0); |
| 964 | if (!drop) |
| 965 | goto error; |
| 966 | *drop = (struct mlx4_drop){ |
| 967 | .priv = priv, |
| 968 | .refcnt = 1, |
| 969 | }; |
| 970 | drop->cq = mlx4_glue->create_cq(priv->ctx, 1, NULL, NULL, 0); |
| 971 | if (!drop->cq) |
| 972 | goto error; |
| 973 | drop->qp = mlx4_glue->create_qp |
| 974 | (priv->pd, |
| 975 | &(struct ibv_qp_init_attr){ |
| 976 | .send_cq = drop->cq, |
| 977 | .recv_cq = drop->cq, |
| 978 | .qp_type = IBV_QPT_RAW_PACKET, |
| 979 | }); |
| 980 | if (!drop->qp) |
| 981 | goto error; |
| 982 | priv->drop = drop; |
| 983 | return drop; |
| 984 | error: |
| 985 | if (drop) { |
| 986 | if (drop->qp) |
| 987 | claim_zero(mlx4_glue->destroy_qp(drop->qp)); |
| 988 | if (drop->cq) |
| 989 | claim_zero(mlx4_glue->destroy_cq(drop->cq)); |
| 990 | rte_free(drop); |
| 991 | } |
| 992 | rte_errno = ENOMEM; |
| 993 | return NULL; |
| 994 | } |
| 995 | |
| 996 | /** |
| 997 | * Give back a drop flow rule resources instance. |
no test coverage detected