本文整理汇总了C++中rte_zmalloc_socket函数的典型用法代码示例。如果您正苦于以下问题:C++ rte_zmalloc_socket函数的具体用法?C++ rte_zmalloc_socket怎么用?C++ rte_zmalloc_socket使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rte_zmalloc_socket函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bnxt_init_rx_ring_struct
int bnxt_init_rx_ring_struct(struct bnxt_rx_queue *rxq, unsigned int socket_id)
{
struct bnxt *bp = rxq->bp;
struct bnxt_cp_ring_info *cpr;
struct bnxt_rx_ring_info *rxr;
struct bnxt_ring *ring;
rxq->rx_buf_use_size = bp->eth_dev->data->mtu +
ETHER_HDR_LEN + ETHER_CRC_LEN +
(2 * VLAN_TAG_SIZE);
rxq->rx_buf_size = rxq->rx_buf_use_size + sizeof(struct rte_mbuf);
rxr = rte_zmalloc_socket("bnxt_rx_ring",
sizeof(struct bnxt_rx_ring_info),
RTE_CACHE_LINE_SIZE, socket_id);
if (rxr == NULL)
return -ENOMEM;
rxq->rx_ring = rxr;
ring = rte_zmalloc_socket("bnxt_rx_ring_struct",
sizeof(struct bnxt_ring),
RTE_CACHE_LINE_SIZE, socket_id);
if (ring == NULL)
return -ENOMEM;
rxr->rx_ring_struct = ring;
ring->ring_size = rte_align32pow2(rxq->nb_rx_desc);
ring->ring_mask = ring->ring_size - 1;
ring->bd = (void *)rxr->rx_desc_ring;
ring->bd_dma = rxr->rx_desc_mapping;
ring->vmem_size = ring->ring_size * sizeof(struct bnxt_sw_rx_bd);
ring->vmem = (void **)&rxr->rx_buf_ring;
cpr = rte_zmalloc_socket("bnxt_rx_ring",
sizeof(struct bnxt_cp_ring_info),
RTE_CACHE_LINE_SIZE, socket_id);
if (cpr == NULL)
return -ENOMEM;
rxq->cp_ring = cpr;
ring = rte_zmalloc_socket("bnxt_rx_ring_struct",
sizeof(struct bnxt_ring),
RTE_CACHE_LINE_SIZE, socket_id);
if (ring == NULL)
return -ENOMEM;
cpr->cp_ring_struct = ring;
ring->ring_size = rxr->rx_ring_struct->ring_size * 2;
ring->ring_mask = ring->ring_size - 1;
ring->bd = (void *)cpr->cp_desc_ring;
ring->bd_dma = cpr->cp_desc_mapping;
ring->vmem_size = 0;
ring->vmem = NULL;
return 0;
}
示例2: bnxt_init_tx_ring_struct
int bnxt_init_tx_ring_struct(struct bnxt_tx_queue *txq, unsigned int socket_id)
{
struct bnxt_cp_ring_info *cpr;
struct bnxt_tx_ring_info *txr;
struct bnxt_ring *ring;
txr = rte_zmalloc_socket("bnxt_tx_ring",
sizeof(struct bnxt_tx_ring_info),
RTE_CACHE_LINE_SIZE, socket_id);
if (txr == NULL)
return -ENOMEM;
txq->tx_ring = txr;
ring = rte_zmalloc_socket("bnxt_tx_ring_struct",
sizeof(struct bnxt_ring),
RTE_CACHE_LINE_SIZE, socket_id);
if (ring == NULL)
return -ENOMEM;
txr->tx_ring_struct = ring;
ring->ring_size = rte_align32pow2(txq->nb_tx_desc + 1);
ring->ring_mask = ring->ring_size - 1;
ring->bd = (void *)txr->tx_desc_ring;
ring->bd_dma = txr->tx_desc_mapping;
ring->vmem_size = ring->ring_size * sizeof(struct bnxt_sw_tx_bd);
ring->vmem = (void **)&txr->tx_buf_ring;
cpr = rte_zmalloc_socket("bnxt_tx_ring",
sizeof(struct bnxt_cp_ring_info),
RTE_CACHE_LINE_SIZE, socket_id);
if (cpr == NULL)
return -ENOMEM;
txq->cp_ring = cpr;
ring = rte_zmalloc_socket("bnxt_tx_ring_struct",
sizeof(struct bnxt_ring),
RTE_CACHE_LINE_SIZE, socket_id);
if (ring == NULL)
return -ENOMEM;
cpr->cp_ring_struct = ring;
ring->ring_size = txr->tx_ring_struct->ring_size;
ring->ring_mask = ring->ring_size - 1;
ring->bd = (void *)cpr->cp_desc_ring;
ring->bd_dma = cpr->cp_desc_mapping;
ring->vmem_size = 0;
ring->vmem = NULL;
return 0;
}
示例3: rte_table_array_create
static void *
rte_table_array_create(void *params, int socket_id, uint32_t entry_size)
{
struct rte_table_array_params *p = params;
struct rte_table_array *t;
uint32_t total_cl_size, total_size;
/* Check input parameters */
if ((p == NULL) ||
(p->n_entries == 0) ||
(!rte_is_power_of_2(p->n_entries)))
return NULL;
/* Memory allocation */
total_cl_size = (sizeof(struct rte_table_array) +
RTE_CACHE_LINE_SIZE) / RTE_CACHE_LINE_SIZE;
total_cl_size += (p->n_entries * entry_size +
RTE_CACHE_LINE_SIZE) / RTE_CACHE_LINE_SIZE;
total_size = total_cl_size * RTE_CACHE_LINE_SIZE;
t = rte_zmalloc_socket("TABLE", total_size, RTE_CACHE_LINE_SIZE, socket_id);
if (t == NULL) {
RTE_LOG(ERR, TABLE,
"%s: Cannot allocate %u bytes for array table\n",
__func__, total_size);
return NULL;
}
/* Memory initialization */
t->entry_size = entry_size;
t->n_entries = p->n_entries;
t->offset = p->offset;
t->entry_pos_mask = t->n_entries - 1;
return t;
}
示例4: dpdk_knidev_writer_create
static void *
dpdk_knidev_writer_create(void *params, int socket_id)
{
struct dpdk_knidev_writer_params *conf =
(struct dpdk_knidev_writer_params *) params;
struct dpdk_knidev_writer *port;
/* Check input parameters */
if ((conf == NULL) ||
(conf->tx_burst_sz == 0) ||
(conf->tx_burst_sz > VR_DPDK_TX_BURST_SZ) ||
(!rte_is_power_of_2(conf->tx_burst_sz))) {
RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
return NULL;
}
/* Memory allocation */
port = rte_zmalloc_socket("PORT", sizeof(*port),
RTE_CACHE_LINE_SIZE, socket_id);
if (port == NULL) {
RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
return NULL;
}
/* Initialization */
port->kni = conf->kni;
port->tx_burst_sz = conf->tx_burst_sz;
port->tx_buf_count = 0;
port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1);
return port;
}
示例5: vmbus_chan_create
int vmbus_chan_create(const struct rte_vmbus_device *device,
uint16_t relid, uint16_t subid, uint8_t monitor_id,
struct vmbus_channel **new_chan)
{
struct vmbus_channel *chan;
int err;
chan = rte_zmalloc_socket("VMBUS", sizeof(*chan), RTE_CACHE_LINE_SIZE,
device->device.numa_node);
if (!chan)
return -ENOMEM;
STAILQ_INIT(&chan->subchannel_list);
chan->device = device;
chan->subchannel_id = subid;
chan->relid = relid;
chan->monitor_id = monitor_id;
*new_chan = chan;
err = vmbus_uio_map_rings(chan);
if (err) {
rte_free(chan);
return err;
}
return 0;
}
示例6: dpdk_knidev_reader_create
static void *
dpdk_knidev_reader_create(void *params, int socket_id)
{
struct dpdk_knidev_reader_params *conf =
(struct dpdk_knidev_reader_params *) params;
struct dpdk_knidev_reader *port;
/* Check input parameters */
if (conf == NULL) {
RTE_LOG(ERR, PORT, "%s: params is NULL\n", __func__);
return NULL;
}
/* Memory allocation */
port = rte_zmalloc_socket("PORT", sizeof(*port),
RTE_CACHE_LINE_SIZE, socket_id);
if (port == NULL) {
RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
return NULL;
}
/* Initialization */
port->kni = conf->kni;
return port;
}
示例7: rte_port_sink_create
static void *
rte_port_sink_create(void *params, int socket_id)
{
struct rte_port_sink *port;
struct rte_port_sink_params *p = params;
/* Memory allocation */
port = rte_zmalloc_socket("PORT", sizeof(*port),
RTE_CACHE_LINE_SIZE, socket_id);
if (port == NULL) {
RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
return NULL;
}
if (!p)
return port;
if (p->file_name) {
int status = PCAP_SINK_OPEN(port, p->file_name,
p->max_n_pkts);
if (status < 0) {
rte_free(port);
port = NULL;
}
}
return port;
}
示例8: rte_port_ring_writer_create_internal
static void *
rte_port_ring_writer_create_internal(void *params, int socket_id,
uint32_t is_multi)
{
struct rte_port_ring_writer_params *conf =
(struct rte_port_ring_writer_params *) params;
struct rte_port_ring_writer *port;
/* Check input parameters */
if ((conf == NULL) ||
(conf->ring == NULL) ||
(conf->ring->prod.sp_enqueue && is_multi) ||
(!(conf->ring->prod.sp_enqueue) && !is_multi) ||
(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) {
RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__);
return NULL;
}
/* Memory allocation */
port = rte_zmalloc_socket("PORT", sizeof(*port),
RTE_CACHE_LINE_SIZE, socket_id);
if (port == NULL) {
RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
return NULL;
}
/* Initialization */
port->ring = conf->ring;
port->tx_burst_sz = conf->tx_burst_sz;
port->tx_buf_count = 0;
port->bsz_mask = 1LLU << (conf->tx_burst_sz - 1);
port->is_multi = is_multi;
return port;
}
示例9: rte_port_fd_writer_create
static void *
rte_port_fd_writer_create(void *params, int socket_id)
{
struct rte_port_fd_writer_params *conf =
params;
struct rte_port_fd_writer *port;
/* Check input parameters */
if ((conf == NULL) ||
(conf->tx_burst_sz == 0) ||
(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX) ||
(!rte_is_power_of_2(conf->tx_burst_sz))) {
RTE_LOG(ERR, PORT, "%s: Invalid input parameters\n", __func__);
return NULL;
}
/* Memory allocation */
port = rte_zmalloc_socket("PORT", sizeof(*port),
RTE_CACHE_LINE_SIZE, socket_id);
if (port == NULL) {
RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
return NULL;
}
/* Initialization */
port->fd = conf->fd;
port->tx_burst_sz = conf->tx_burst_sz;
port->tx_buf_count = 0;
return port;
}
示例10: rte_port_ring_reader_create_internal
static void *
rte_port_ring_reader_create_internal(void *params, int socket_id,
uint32_t is_multi)
{
struct rte_port_ring_reader_params *conf =
(struct rte_port_ring_reader_params *) params;
struct rte_port_ring_reader *port;
/* Check input parameters */
if ((conf == NULL) ||
(conf->ring == NULL) ||
(conf->ring->cons.sc_dequeue && is_multi) ||
(!(conf->ring->cons.sc_dequeue) && !is_multi)) {
RTE_LOG(ERR, PORT, "%s: Invalid Parameters\n", __func__);
return NULL;
}
/* Memory allocation */
port = rte_zmalloc_socket("PORT", sizeof(*port),
RTE_CACHE_LINE_SIZE, socket_id);
if (port == NULL) {
RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
return NULL;
}
/* Initialization */
port->ring = conf->ring;
return port;
}
示例11: rte_port_source_create
static void *
rte_port_source_create(void *params, int socket_id)
{
struct rte_port_source_params *p =
(struct rte_port_source_params *) params;
struct rte_port_source *port;
/* Check input arguments*/
if ((p == NULL) || (p->mempool == NULL)) {
RTE_LOG(ERR, PORT, "%s: Invalid params\n", __func__);
return NULL;
}
/* Memory allocation */
port = rte_zmalloc_socket("PORT", sizeof(*port),
CACHE_LINE_SIZE, socket_id);
if (port == NULL) {
RTE_LOG(ERR, PORT, "%s: Failed to allocate port\n", __func__);
return NULL;
}
/* Initialization */
port->mempool = (struct rte_mempool *) p->mempool;
return port;
}
示例12: rte_port_ring_writer_ras_create
static void *
rte_port_ring_writer_ras_create(void *params, int socket_id, int is_ipv4)
{
struct rte_port_ring_writer_ras_params *conf =
params;
struct rte_port_ring_writer_ras *port;
uint64_t frag_cycles;
/* Check input parameters */
if (conf == NULL) {
RTE_LOG(ERR, PORT, "%s: Parameter conf is NULL\n", __func__);
return NULL;
}
if (conf->ring == NULL) {
RTE_LOG(ERR, PORT, "%s: Parameter ring is NULL\n", __func__);
return NULL;
}
if ((conf->tx_burst_sz == 0) ||
(conf->tx_burst_sz > RTE_PORT_IN_BURST_SIZE_MAX)) {
RTE_LOG(ERR, PORT, "%s: Parameter tx_burst_sz is invalid\n",
__func__);
return NULL;
}
/* Memory allocation */
port = rte_zmalloc_socket("PORT", sizeof(*port),
RTE_CACHE_LINE_SIZE, socket_id);
if (port == NULL) {
RTE_LOG(ERR, PORT, "%s: Failed to allocate socket\n", __func__);
return NULL;
}
/* Create fragmentation table */
frag_cycles = (rte_get_tsc_hz() + MS_PER_S - 1) / MS_PER_S * MS_PER_S;
frag_cycles *= 100;
port->frag_tbl = rte_ip_frag_table_create(
RTE_PORT_RAS_N_BUCKETS,
RTE_PORT_RAS_N_ENTRIES_PER_BUCKET,
RTE_PORT_RAS_N_ENTRIES,
frag_cycles,
socket_id);
if (port->frag_tbl == NULL) {
RTE_LOG(ERR, PORT, "%s: rte_ip_frag_table_create failed\n",
__func__);
rte_free(port);
return NULL;
}
/* Initialization */
port->ring = conf->ring;
port->tx_burst_sz = conf->tx_burst_sz;
port->tx_buf_count = 0;
port->f_ras = (is_ipv4 == 1) ? process_ipv4 : process_ipv6;
return port;
}
示例13: rte_lpm_create
/*
* Allocates memory for LPM object
*/
struct rte_lpm *
rte_lpm_create(const char *name, int socket_id, int max_rules,
__rte_unused int flags)
{
char mem_name[RTE_LPM_NAMESIZE];
struct rte_lpm *lpm = NULL;
uint32_t mem_size;
struct rte_lpm_list *lpm_list;
/* check that we have an initialised tail queue */
if ((lpm_list =
RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_LPM, rte_lpm_list)) == NULL) {
rte_errno = E_RTE_NO_TAILQ;
return NULL;
}
RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl24_entry) != 2);
RTE_BUILD_BUG_ON(sizeof(struct rte_lpm_tbl8_entry) != 2);
/* Check user arguments. */
if ((name == NULL) || (socket_id < -1) || (max_rules == 0)){
rte_errno = EINVAL;
return NULL;
}
rte_snprintf(mem_name, sizeof(mem_name), "LPM_%s", name);
/* Determine the amount of memory to allocate. */
mem_size = sizeof(*lpm) + (sizeof(lpm->rules_tbl[0]) * max_rules);
rte_rwlock_write_lock(RTE_EAL_TAILQ_RWLOCK);
/* guarantee there's no existing */
TAILQ_FOREACH(lpm, lpm_list, next) {
if (strncmp(name, lpm->name, RTE_LPM_NAMESIZE) == 0)
break;
}
if (lpm != NULL)
goto exit;
/* Allocate memory to store the LPM data structures. */
lpm = (struct rte_lpm *)rte_zmalloc_socket(mem_name, mem_size,
CACHE_LINE_SIZE, socket_id);
if (lpm == NULL) {
RTE_LOG(ERR, LPM, "LPM memory allocation failed\n");
goto exit;
}
/* Save user arguments. */
lpm->max_rules = max_rules;
rte_snprintf(lpm->name, sizeof(lpm->name), "%s", name);
TAILQ_INSERT_TAIL(lpm_list, lpm, next);
exit:
rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK);
return lpm;
}
示例14: null_crypto_pmd_qp_setup
/** Setup a queue pair */
static int
null_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id,
const struct rte_cryptodev_qp_conf *qp_conf,
int socket_id, struct rte_mempool *session_pool)
{
struct null_crypto_private *internals = dev->data->dev_private;
struct null_crypto_qp *qp;
int retval;
if (qp_id >= internals->max_nb_qpairs) {
NULL_CRYPTO_LOG_ERR("Invalid qp_id %u, greater than maximum "
"number of queue pairs supported (%u).",
qp_id, internals->max_nb_qpairs);
return (-EINVAL);
}
/* Free memory prior to re-allocation if needed. */
if (dev->data->queue_pairs[qp_id] != NULL)
null_crypto_pmd_qp_release(dev, qp_id);
/* Allocate the queue pair data structure. */
qp = rte_zmalloc_socket("Null Crypto PMD Queue Pair", sizeof(*qp),
RTE_CACHE_LINE_SIZE, socket_id);
if (qp == NULL) {
NULL_CRYPTO_LOG_ERR("Failed to allocate queue pair memory");
return (-ENOMEM);
}
qp->id = qp_id;
dev->data->queue_pairs[qp_id] = qp;
retval = null_crypto_pmd_qp_set_unique_name(dev, qp);
if (retval) {
NULL_CRYPTO_LOG_ERR("Failed to create unique name for null "
"crypto device");
goto qp_setup_cleanup;
}
qp->processed_pkts = null_crypto_pmd_qp_create_processed_pkts_ring(qp,
qp_conf->nb_descriptors, socket_id);
if (qp->processed_pkts == NULL) {
NULL_CRYPTO_LOG_ERR("Failed to create unique name for null "
"crypto device");
goto qp_setup_cleanup;
}
qp->sess_mp = session_pool;
memset(&qp->qp_stats, 0, sizeof(qp->qp_stats));
return 0;
qp_setup_cleanup:
if (qp)
rte_free(qp);
return -1;
}
示例15: rte_event_dev_queue_config
static inline int
rte_event_dev_queue_config(struct rte_eventdev *dev, uint8_t nb_queues)
{
uint8_t old_nb_queues = dev->data->nb_queues;
struct rte_event_queue_conf *queues_cfg;
unsigned int i;
RTE_EDEV_LOG_DEBUG("Setup %d queues on device %u", nb_queues,
dev->data->dev_id);
/* First time configuration */
if (dev->data->queues_cfg == NULL && nb_queues != 0) {
/* Allocate memory to store queue configuration */
dev->data->queues_cfg = rte_zmalloc_socket(
"eventdev->data->queues_cfg",
sizeof(dev->data->queues_cfg[0]) * nb_queues,
RTE_CACHE_LINE_SIZE, dev->data->socket_id);
if (dev->data->queues_cfg == NULL) {
dev->data->nb_queues = 0;
RTE_EDEV_LOG_ERR("failed to get mem for queue cfg,"
"nb_queues %u", nb_queues);
return -(ENOMEM);
}
/* Re-configure */
} else if (dev->data->queues_cfg != NULL && nb_queues != 0) {
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_release, -ENOTSUP);
for (i = nb_queues; i < old_nb_queues; i++)
(*dev->dev_ops->queue_release)(dev, i);
/* Re allocate memory to store queue configuration */
queues_cfg = dev->data->queues_cfg;
queues_cfg = rte_realloc(queues_cfg,
sizeof(queues_cfg[0]) * nb_queues,
RTE_CACHE_LINE_SIZE);
if (queues_cfg == NULL) {
RTE_EDEV_LOG_ERR("failed to realloc queue cfg memory,"
" nb_queues %u", nb_queues);
return -(ENOMEM);
}
dev->data->queues_cfg = queues_cfg;
if (nb_queues > old_nb_queues) {
uint8_t new_qs = nb_queues - old_nb_queues;
memset(queues_cfg + old_nb_queues, 0,
sizeof(queues_cfg[0]) * new_qs);
}
} else if (dev->data->queues_cfg != NULL && nb_queues == 0) {
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->queue_release, -ENOTSUP);
for (i = nb_queues; i < old_nb_queues; i++)
(*dev->dev_ops->queue_release)(dev, i);
}
dev->data->nb_queues = nb_queues;
return 0;
}