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

Function mlx5_txpp_alloc_pp_index

dpdk/drivers/net/mlx5/mlx5_txpp.c:79–129  ·  view source on GitHub ↗

Allocate Packet Pacing index from kernel via mlx5dv call. */

Source from the content-addressed store, hash-verified

77
78/* Allocate Packet Pacing index from kernel via mlx5dv call. */
79static int
80mlx5_txpp_alloc_pp_index(struct mlx5_dev_ctx_shared *sh)
81{
82#ifdef HAVE_MLX5DV_PP_ALLOC
83 uint32_t pp[MLX5_ST_SZ_DW(set_pp_rate_limit_context)];
84 uint64_t rate;
85
86 MLX5_ASSERT(!sh->txpp.pp);
87 memset(&pp, 0, sizeof(pp));
88 rate = NS_PER_S / sh->txpp.tick;
89 if (rate * sh->txpp.tick != NS_PER_S)
90 DRV_LOG(WARNING, "Packet pacing frequency is not precise.");
91 if (sh->txpp.test) {
92 uint32_t len;
93
94 len = RTE_MAX(MLX5_TXPP_TEST_PKT_SIZE,
95 (size_t)RTE_ETHER_MIN_LEN);
96 MLX5_SET(set_pp_rate_limit_context, &pp,
97 burst_upper_bound, len);
98 MLX5_SET(set_pp_rate_limit_context, &pp,
99 typical_packet_size, len);
100 /* Convert packets per second into kilobits. */
101 rate = (rate * len) / (1000ul / CHAR_BIT);
102 DRV_LOG(INFO, "Packet pacing rate set to %" PRIu64, rate);
103 }
104 MLX5_SET(set_pp_rate_limit_context, &pp, rate_limit, rate);
105 MLX5_SET(set_pp_rate_limit_context, &pp, rate_mode,
106 sh->txpp.test ? MLX5_DATA_RATE : MLX5_WQE_RATE);
107 sh->txpp.pp = mlx5_glue->dv_alloc_pp
108 (sh->cdev->ctx, sizeof(pp), &pp,
109 MLX5DV_PP_ALLOC_FLAGS_DEDICATED_INDEX);
110 if (sh->txpp.pp == NULL) {
111 DRV_LOG(ERR, "Failed to allocate packet pacing index.");
112 rte_errno = errno;
113 return -errno;
114 }
115 if (!((struct mlx5dv_pp *)sh->txpp.pp)->index) {
116 DRV_LOG(ERR, "Zero packet pacing index allocated.");
117 mlx5_txpp_free_pp_index(sh);
118 rte_errno = ENOTSUP;
119 return -ENOTSUP;
120 }
121 sh->txpp.pp_id = ((struct mlx5dv_pp *)(sh->txpp.pp))->index;
122 return 0;
123#else
124 RTE_SET_USED(sh);
125 DRV_LOG(ERR, "Allocating pacing index is not supported.");
126 rte_errno = ENOTSUP;
127 return -ENOTSUP;
128#endif
129}
130
131static void
132mlx5_txpp_destroy_send_queue(struct mlx5_txpp_wq *wq)

Callers 1

mlx5_txpp_createFunction · 0.85

Calls 2

memsetFunction · 0.85
mlx5_txpp_free_pp_indexFunction · 0.85

Tested by

no test coverage detected