MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mlx4_drop_get

Function mlx4_drop_get

dpdk/drivers/net/mlx4/mlx4_flow.c:952–994  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

950 * is set.
951 */
952static struct mlx4_drop *
953mlx4_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;
984error:
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.

Callers 1

mlx4_flow_toggleFunction · 0.85

Calls 2

rte_mallocFunction · 0.85
rte_freeFunction · 0.85

Tested by

no test coverage detected