本文整理汇总了C++中rte_memcpy函数的典型用法代码示例。如果您正苦于以下问题:C++ rte_memcpy函数的具体用法?C++ rte_memcpy怎么用?C++ rte_memcpy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rte_memcpy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: classify_pattern_skip_void_item
/* Skip all VOID items of the pattern */
void
classify_pattern_skip_void_item(struct rte_flow_item *items,
const struct rte_flow_item *pattern)
{
uint32_t cpy_count = 0;
const struct rte_flow_item *pb = pattern, *pe = pattern;
for (;;) {
/* Find a non-void item first */
pb = classify_find_first_item(pb, false);
if (pb->type == RTE_FLOW_ITEM_TYPE_END) {
pe = pb;
break;
}
/* Find a void item */
pe = classify_find_first_item(pb + 1, true);
cpy_count = pe - pb;
rte_memcpy(items, pb, sizeof(struct rte_flow_item) * cpy_count);
items += cpy_count;
if (pe->type == RTE_FLOW_ITEM_TYPE_END) {
pb = pe;
break;
}
pb = pe + 1;
}
/* Copy the END item. */
rte_memcpy(items, pe, sizeof(struct rte_flow_item));
}
开发者ID:cleveritcz,项目名称:f-stack,代码行数:34,代码来源:rte_flow_classify_parse.c
示例2: copy_buf_to_pkt_segs
static void
copy_buf_to_pkt_segs(void* buf, unsigned len, struct rte_mbuf *pkt,
unsigned offset)
{
struct rte_mbuf *seg;
void *seg_buf;
unsigned copy_len;
seg = pkt;
while (offset >= seg->data_len) {
offset -= seg->data_len;
seg = seg->next;
}
copy_len = seg->data_len - offset;
seg_buf = rte_pktmbuf_mtod_offset(seg, char *, offset);
while (len > copy_len) {
rte_memcpy(seg_buf, buf, (size_t) copy_len);
len -= copy_len;
buf = ((char*) buf + copy_len);
seg = seg->next;
seg_buf = rte_pktmbuf_mtod(seg, char *);
copy_len = seg->data_len;
}
rte_memcpy(seg_buf, buf, (size_t) len);
}
开发者ID:cleveritcz,项目名称:f-stack,代码行数:25,代码来源:txonly.c
示例3: addr_sa_to_xaddr
int addr_sa_to_xaddr(struct sockaddr* sa, socklen_t slen, struct xaddr* xa) {
struct sockaddr_in* in4 = (struct sockaddr_in*)sa;
struct sockaddr_in6* in6 = (struct sockaddr_in6*)sa;
memset(xa, '\0', sizeof(*xa));
switch (sa->sa_family) {
case AF_INET:
if (slen < sizeof(*in4))
return (-1);
xa->af = AF_INET;
rte_memcpy(&xa->v4, &in4->sin_addr, sizeof(xa->v4));
break;
case AF_INET6:
if (slen < sizeof(*in6))
return (-1);
xa->af = AF_INET6;
rte_memcpy(&xa->v6, &in6->sin6_addr, sizeof(xa->v6));
xa->scope_id = in6->sin6_scope_id;
break;
default:
return (-1);
}
return (0);
}
开发者ID:megahall,项目名称:sdn_sensor,代码行数:26,代码来源:netflow_addr.c
示例4: file_read_cached
static int file_read_cached(const char *file_name, uint8_t **mem, uint32_t beg, uint32_t len, uint32_t socket, struct hash_set *hs)
{
if (len == 0) {
*mem = 0;
return 0;
}
uint8_t *data_mem;
/* Since the configuration can reference the same file from
multiple places, use prox_shared infrastructure to detect
this and return previously loaded data. */
char name[256];
snprintf(name, sizeof(name), "%u-%u:%s", beg, len, file_name);
*mem = prox_sh_find_socket(socket, name);
if (*mem)
return 0;
/* check if the file has been loaded on the other socket. */
if (socket == 1 && (data_mem = prox_sh_find_socket(0, name))) {
uint8_t *data_find = hash_set_find(hs, data_mem, len);
if (!data_find) {
data_find = prox_zmalloc(len, socket);
PROX_PANIC(data_find == NULL, "Failed to allocate memory (%u bytes) to hold header for peer\n", len);
rte_memcpy(data_find, data_mem, len);
hash_set_add(hs, data_find, len);
}
*mem = data_find;
prox_sh_add_socket(socket, name, *mem);
return 0;
}
/* It is possible that a file with a different name contains
the same data. In that case, search all loaded files and
compare the data to reduce memory utilization.*/
data_mem = malloc(len);
PROX_PANIC(data_mem == NULL, "Failed to allocate temporary memory to hold data\n");
if (file_read_content(file_name, data_mem, beg, len)) {
plog_err("%s\n", file_get_error());
return -1;
}
uint8_t *data_find = hash_set_find(hs, data_mem, len);
if (!data_find) {
data_find = prox_zmalloc(len, socket);
PROX_PANIC(data_find == NULL, "Failed to allocate memory (%u bytes) to hold header for peer\n", len);
rte_memcpy(data_find, data_mem, len);
hash_set_add(hs, data_find, len);
}
free(data_mem);
*mem = data_find;
prox_sh_add_socket(socket, name, *mem);
return 0;
}
开发者ID:nvf-crucio,项目名称:PROX,代码行数:60,代码来源:handle_genl4.c
示例5: dpdk_link_send_bulk
/* Sends 'num_pkts' 'packets' and 'request' data to datapath. */
int
dpdk_link_send_bulk(struct dpif_dpdk_message *request,
const struct ofpbuf *const *packets, size_t num_pkts)
{
struct rte_mbuf *mbufs[PKT_BURST_SIZE] = {NULL};
uint8_t *mbuf_data = NULL;
int i = 0;
int ret = 0;
if (num_pkts > PKT_BURST_SIZE) {
return EINVAL;
}
DPDK_DEBUG()
for (i = 0; i < num_pkts; i++) {
mbufs[i] = rte_pktmbuf_alloc(mp);
if (!mbufs[i]) {
return ENOBUFS;
}
mbuf_data = rte_pktmbuf_mtod(mbufs[i], uint8_t *);
rte_memcpy(mbuf_data, &request[i], sizeof(request[i]));
if (request->type == DPIF_DPDK_PACKET_FAMILY) {
mbuf_data = mbuf_data + sizeof(request[i]);
if (likely(packets[i]->size <= (mbufs[i]->buf_len - sizeof(request[i])))) {
rte_memcpy(mbuf_data, packets[i]->data, packets[i]->size);
rte_pktmbuf_data_len(mbufs[i]) =
sizeof(request[i]) + packets[i]->size;
rte_pktmbuf_pkt_len(mbufs[i]) = rte_pktmbuf_data_len(mbufs[i]);
} else {
RTE_LOG(ERR, APP, "%s, %d: %s", __FUNCTION__, __LINE__,
"memcpy prevented: packet size exceeds available mbuf space");
for (i = 0; i < num_pkts; i++) {
rte_pktmbuf_free(mbufs[i]);
}
return ENOMEM;
}
} else {
rte_pktmbuf_data_len(mbufs[i]) = sizeof(request[i]);
rte_pktmbuf_pkt_len(mbufs[i]) = rte_pktmbuf_data_len(mbufs[i]);
}
}
ret = rte_ring_sp_enqueue_bulk(message_ring, (void * const *)mbufs, num_pkts);
if (ret == -ENOBUFS) {
for (i = 0; i < num_pkts; i++) {
rte_pktmbuf_free(mbufs[i]);
}
ret = ENOBUFS;
} else if (unlikely(ret == -EDQUOT)) {
ret = EDQUOT;
}
return ret;
}
开发者ID:kikutak,项目名称:dpdk-ovs,代码行数:59,代码来源:dpdk-link.c
示例6: lio_mbox_process_message
/**
* Process the received mbox message.
*/
int
lio_mbox_process_message(struct lio_mbox *mbox)
{
struct lio_mbox_cmd mbox_cmd;
if (mbox->state & LIO_MBOX_STATE_ERROR) {
if (mbox->state & (LIO_MBOX_STATE_RES_PENDING |
LIO_MBOX_STATE_RES_RECEIVING)) {
rte_memcpy(&mbox_cmd, &mbox->mbox_resp,
sizeof(struct lio_mbox_cmd));
mbox->state = LIO_MBOX_STATE_IDLE;
rte_write64(LIO_PFVFSIG, mbox->mbox_read_reg);
mbox_cmd.recv_status = 1;
if (mbox_cmd.fn)
mbox_cmd.fn(mbox->lio_dev, &mbox_cmd,
mbox_cmd.fn_arg);
return 0;
}
mbox->state = LIO_MBOX_STATE_IDLE;
rte_write64(LIO_PFVFSIG, mbox->mbox_read_reg);
return 0;
}
if (mbox->state & LIO_MBOX_STATE_RES_RECEIVED) {
rte_memcpy(&mbox_cmd, &mbox->mbox_resp,
sizeof(struct lio_mbox_cmd));
mbox->state = LIO_MBOX_STATE_IDLE;
rte_write64(LIO_PFVFSIG, mbox->mbox_read_reg);
mbox_cmd.recv_status = 0;
if (mbox_cmd.fn)
mbox_cmd.fn(mbox->lio_dev, &mbox_cmd, mbox_cmd.fn_arg);
return 0;
}
if (mbox->state & LIO_MBOX_STATE_REQ_RECEIVED) {
rte_memcpy(&mbox_cmd, &mbox->mbox_req,
sizeof(struct lio_mbox_cmd));
if (!mbox_cmd.msg.s.resp_needed) {
mbox->state &= ~LIO_MBOX_STATE_REQ_RECEIVED;
if (!(mbox->state & LIO_MBOX_STATE_RES_PENDING))
mbox->state = LIO_MBOX_STATE_IDLE;
rte_write64(LIO_PFVFSIG, mbox->mbox_read_reg);
}
lio_mbox_process_cmd(mbox, &mbox_cmd);
return 0;
}
RTE_ASSERT(0);
return 0;
}
开发者ID:DrenfongWong,项目名称:dpdk,代码行数:60,代码来源:lio_mbox.c
示例7: pktgen_send_arp
void
pktgen_send_arp( uint32_t pid, uint32_t type, uint8_t seq_idx )
{
port_info_t * info = &pktgen.info[pid];
pkt_seq_t * pkt;
struct rte_mbuf * m ;
struct ether_hdr * eth;
arpPkt_t * arp;
uint32_t addr;
uint8_t qid = 0;
pkt = &info->seq_pkt[seq_idx];
m = rte_pktmbuf_alloc(info->q[qid].special_mp);
if ( unlikely(m == NULL) ) {
pktgen_log_warning("No packet buffers found");
return;
}
eth = rte_pktmbuf_mtod(m, struct ether_hdr *);
arp = (arpPkt_t *)ð[1];
/* src and dest addr */
memset(ð->d_addr, 0xFF, 6);
ether_addr_copy(&pkt->eth_src_addr, ð->s_addr);
eth->ether_type = htons(ETHER_TYPE_ARP);
memset(arp, 0, sizeof(arpPkt_t));
rte_memcpy( &arp->sha, &pkt->eth_src_addr, 6 );
addr = htonl(pkt->ip_src_addr);
inetAddrCopy(&arp->spa, &addr);
if ( likely(type == GRATUITOUS_ARP) ) {
rte_memcpy( &arp->tha, &pkt->eth_src_addr, 6 );
addr = htonl(pkt->ip_src_addr);
inetAddrCopy(&arp->tpa, &addr);
} else {
memset( &arp->tha, 0, 6 );
addr = htonl(pkt->ip_dst_addr);
inetAddrCopy(&arp->tpa, &addr);
}
/* Fill in the rest of the ARP packet header */
arp->hrd = htons(ETH_HW_TYPE);
arp->pro = htons(ETHER_TYPE_IPv4);
arp->hln = 6;
arp->pln = 4;
arp->op = htons(ARP_REQUEST);
m->pkt.pkt_len = 60;
m->pkt.data_len = 60;
pktgen_send_mbuf(m, pid, qid);
pktgen_set_q_flags(info, qid, DO_TX_FLUSH);
}
开发者ID:AdunSG,项目名称:Pktgen-DPDK,代码行数:55,代码来源:pktgen-arp.c
示例8: qCritical
/**
* @brief Copy a buffer to mbuf
*
* @param devId port number
* @param data Data buffer
* @param dataLen Data buffer length
* @param pMbuf mbuf
*
* @return true on success
*/
bool DPDKAdapter::copyBufToMbuf(uint8_t devId, char* data, unsigned int dataLen, MBuf_t*& pMbuf)
{
unsigned int offset = 0;
pMbuf = NULL;
pMbuf = DPDKAdapter::instance()->txMbufAlloc(devId);
if (pMbuf == NULL)
{
qCritical("No mbuf available");
return false;
}
pMbuf->pkt.data_len = dataLen < MAX_SEG_SIZE ? dataLen : MAX_SEG_SIZE;
pMbuf->pkt.pkt_len = dataLen;
pMbuf->pkt.nb_segs = (dataLen / MAX_SEG_SIZE) + ((dataLen % MAX_SEG_SIZE) || 0);
qDebug("pkt_len %u, data_len %u, nb_segs %u",pMbuf->pkt.pkt_len, pMbuf->pkt.data_len, pMbuf->pkt.nb_segs);
rte_memcpy(pMbuf->pkt.data, data, pMbuf->pkt.data_len);
if (dataLen <= MAX_SEG_SIZE)
{
return true;
}
dataLen -= pMbuf->pkt.data_len;
offset = pMbuf->pkt.data_len;
MBuf_t* pCurMbuf = pMbuf;
while (dataLen > 0)
{
qDebug("offset %u, dataLen %u", offset, dataLen);
pCurMbuf->pkt.next = DPDKAdapter::instance()->txMbufAlloc(devId);
if (pCurMbuf->pkt.next == NULL)
{
qCritical("No mbuf available");
return false;
}
pCurMbuf = pCurMbuf->pkt.next;
pCurMbuf->pkt.data_len = dataLen < MAX_SEG_SIZE ? dataLen : MAX_SEG_SIZE;
qDebug("pkt_len %u, data_len %u, nb_segs %u",pCurMbuf->pkt.pkt_len, pCurMbuf->pkt.data_len, pCurMbuf->pkt.nb_segs);
rte_memcpy(pCurMbuf->pkt.data, data + offset, pCurMbuf->pkt.data_len);
dataLen -= pCurMbuf->pkt.data_len;
offset += pCurMbuf->pkt.data_len;
}
return true;
}
开发者ID:sdnnfv,项目名称:dpdkadapter,代码行数:65,代码来源:dpdk_adapter.cpp
示例9: trace_entry_dump
/*****************************************************************************
* trace_entry_dump()
****************************************************************************/
void trace_entry_dump(trace_printer_cb_t printer, void *printer_arg,
trace_printer_fmt_cb_t fmt, const char *comp_name,
const char *buffer, uint32_t bufsize, uint32_t *start_id,
uint32_t *start_pos, uint32_t end_pos)
{
uint32_t old_start = *start_pos;
uint32_t start_raw;
trace_level_t te_lvl;
uint32_t te_len;
uint32_t len_to_copy;
trace_entry_hdr_peek_buf(buffer, bufsize, old_start, start_id,
&te_lvl, &te_len);
len_to_copy = te_len - offsetof(trace_entry_t, te_buf);
start_raw = (old_start + offsetof(trace_entry_t, te_buf)) % bufsize;
if (start_raw + len_to_copy > bufsize) {
/* LOCAL copy! */
char raw_entry[len_to_copy];
rte_memcpy(raw_entry, &buffer[start_raw], bufsize - start_raw);
rte_memcpy(&raw_entry[bufsize - start_raw], buffer,
len_to_copy - (bufsize - start_raw));
if (fmt) {
char *fmt_data = fmt(raw_entry, te_len);
printer(printer_arg, te_lvl, comp_name, fmt_data,
strlen(fmt_data));
} else
printer(printer_arg, te_lvl, comp_name, raw_entry, te_len);
*start_pos = len_to_copy - (bufsize - start_raw);
} else {
if (fmt) {
char *fmt_data = fmt(&buffer[start_raw], te_len);
printer(printer_arg, te_lvl, comp_name, fmt_data,
strlen(fmt_data));
} else
printer(printer_arg, te_lvl, comp_name,
&buffer[start_raw], te_len);
*start_pos = (old_start + te_len) % bufsize;
}
/* Look at the next entry too in order to return the new id. */
if (*start_pos != end_pos)
trace_entry_hdr_peek_buf(buffer, bufsize, *start_pos, start_id,
NULL,
NULL);
}
开发者ID:Juniper,项目名称:warp17,代码行数:54,代码来源:tpg_trace.c
示例10: get_eth_conf
/* Builds up the correct configuration for vmdq+dcb based on the vlan tags array
* given above, and the number of traffic classes available for use. */
static inline int
get_eth_conf(struct rte_eth_conf *eth_conf)
{
struct rte_eth_vmdq_dcb_conf conf;
struct rte_eth_vmdq_rx_conf vmdq_conf;
struct rte_eth_dcb_rx_conf dcb_conf;
struct rte_eth_vmdq_dcb_tx_conf tx_conf;
uint8_t i;
conf.nb_queue_pools = (enum rte_eth_nb_pools)num_pools;
vmdq_conf.nb_queue_pools = (enum rte_eth_nb_pools)num_pools;
tx_conf.nb_queue_pools = (enum rte_eth_nb_pools)num_pools;
conf.nb_pool_maps = num_pools;
vmdq_conf.nb_pool_maps = num_pools;
conf.enable_default_pool = 0;
vmdq_conf.enable_default_pool = 0;
conf.default_pool = 0; /* set explicit value, even if not used */
vmdq_conf.default_pool = 0;
for (i = 0; i < conf.nb_pool_maps; i++) {
conf.pool_map[i].vlan_id = vlan_tags[i];
vmdq_conf.pool_map[i].vlan_id = vlan_tags[i];
conf.pool_map[i].pools = 1UL << i;
vmdq_conf.pool_map[i].pools = 1UL << i;
}
for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++){
conf.dcb_tc[i] = i % num_tcs;
dcb_conf.dcb_tc[i] = i % num_tcs;
tx_conf.dcb_tc[i] = i % num_tcs;
}
dcb_conf.nb_tcs = (enum rte_eth_nb_tcs)num_tcs;
(void)(rte_memcpy(eth_conf, &vmdq_dcb_conf_default, sizeof(*eth_conf)));
(void)(rte_memcpy(ð_conf->rx_adv_conf.vmdq_dcb_conf, &conf,
sizeof(conf)));
(void)(rte_memcpy(ð_conf->rx_adv_conf.dcb_rx_conf, &dcb_conf,
sizeof(dcb_conf)));
(void)(rte_memcpy(ð_conf->rx_adv_conf.vmdq_rx_conf, &vmdq_conf,
sizeof(vmdq_conf)));
(void)(rte_memcpy(ð_conf->tx_adv_conf.vmdq_dcb_tx_conf, &tx_conf,
sizeof(tx_conf)));
if (rss_enable) {
eth_conf->rxmode.mq_mode = ETH_MQ_RX_VMDQ_DCB_RSS;
eth_conf->rx_adv_conf.rss_conf.rss_hf = ETH_RSS_IP |
ETH_RSS_UDP |
ETH_RSS_TCP |
ETH_RSS_SCTP;
}
return 0;
}
开发者ID:cleveritcz,项目名称:f-stack,代码行数:51,代码来源:main.c
示例11: qede_alloc_etherdev
static void
qede_alloc_etherdev(struct qede_dev *qdev, struct qed_dev_eth_info *info)
{
rte_memcpy(&qdev->dev_info, info, sizeof(*info));
qdev->num_tc = qdev->dev_info.num_tc;
qdev->ops = qed_ops;
}
开发者ID:RIFTIO,项目名称:dpdk,代码行数:7,代码来源:qede_ethdev.c
示例12: addr_pton_cidr
int addr_pton_cidr(const char* p, struct xaddr* n, int* l) {
struct xaddr tmp;
int masklen = -1;
char addrbuf[64];
char* mp;
char* cp;
/* Don't modify argument */
if (p == NULL || strlcpy(addrbuf, p,
sizeof(addrbuf)) >= sizeof(addrbuf))
return (-1);
if ((mp = strchr(addrbuf, '/')) != NULL) {
*mp = '\0';
mp++;
masklen = (int) strtol(mp, &cp, 10);
if (*mp == '\0' || *cp != '\0' || masklen > 128)
return (-1);
}
if (addr_pton(addrbuf, &tmp) == -1)
return (-1);
if (mp == NULL)
masklen = addr_unicast_masklen(tmp.af);
if (addr_masklen_valid(tmp.af, masklen) == -1)
return (-1);
if (n != NULL)
rte_memcpy(n, &tmp, sizeof(*n));
if (l != NULL)
*l = masklen;
return (0);
}
开发者ID:megahall,项目名称:sdn_sensor,代码行数:35,代码来源:netflow_addr.c
示例13: qDebug
/**
* @brief Copy all mbuf segments to a buffer
*
* @param devId port number
* @param pMbuf mbuf
* @param data Data buffer
* @param dataLen Data buffer length
*
* @return true on success
*/
bool DPDKAdapter::copyMbufToBuf(uint8_t devId, MBuf_t* pMbuf, char* data, unsigned int& dataLen)
{
qDebug("pkt_len %u, data_len %u, nb_segs %u", pMbuf->pkt.pkt_len, pMbuf->pkt.data_len, pMbuf->pkt.nb_segs);
unsigned int segCnt = pMbuf->pkt.nb_segs;
unsigned int offset = 0;
MBuf_t* pNextMbuf = pMbuf;
dataLen = pMbuf->pkt.pkt_len;
while (segCnt > 0)
{
MBuf_t* pCurMbuf = pNextMbuf;
qDebug("segCnt %u, offset %u", segCnt, offset);
rte_memcpy(data + offset, pCurMbuf->pkt.data, pCurMbuf->pkt.data_len);
qDebug("pkt_len %u, data_len %u", pCurMbuf->pkt.pkt_len, pCurMbuf->pkt.data_len);
offset += pCurMbuf->pkt.data_len;
pNextMbuf = pCurMbuf->pkt.next;
rte_pktmbuf_free(pCurMbuf);
segCnt--;
}
return true;
}
开发者ID:sdnnfv,项目名称:dpdkadapter,代码行数:39,代码来源:dpdk_adapter.cpp
示例14: rte_port_source_rx
static int
rte_port_source_rx(void *port, struct rte_mbuf **pkts, uint32_t n_pkts)
{
struct rte_port_source *p = port;
uint32_t i;
if (rte_pktmbuf_alloc_bulk(p->mempool, pkts, n_pkts) != 0)
return 0;
if (p->pkt_buff != NULL) {
for (i = 0; i < n_pkts; i++) {
uint8_t *pkt_data = rte_pktmbuf_mtod(pkts[i],
uint8_t *);
rte_memcpy(pkt_data, p->pkts[p->pkt_index],
p->pkt_len[p->pkt_index]);
pkts[i]->data_len = p->pkt_len[p->pkt_index];
pkts[i]->pkt_len = pkts[i]->data_len;
p->pkt_index++;
if (p->pkt_index >= p->n_pkts)
p->pkt_index = 0;
}
}
RTE_PORT_SOURCE_STATS_PKTS_IN_ADD(p, n_pkts);
return n_pkts;
}
开发者ID:InNetworkFiltering,项目名称:SGX-DPDK,代码行数:29,代码来源:rte_port_source_sink.c
示例15: pktgen_send_ping4
void
pktgen_send_ping4( uint32_t pid, uint8_t seq_idx )
{
port_info_t * info = &pktgen.info[pid];
pkt_seq_t * ppkt = &info->seq_pkt[PING_PKT];
pkt_seq_t * spkt = &info->seq_pkt[seq_idx];
struct rte_mbuf * m ;
uint8_t qid = 0;
m = rte_pktmbuf_alloc(info->q[qid].special_mp);
if ( unlikely(m == NULL) ) {
pktgen_log_warning("No packet buffers found");
return;
}
*ppkt = *spkt; // Copy the sequence setup to the ping setup.
pktgen_packet_ctor(info, PING_PKT, ICMP4_ECHO);
rte_memcpy((uint8_t *)m->buf_addr + m->data_off, (uint8_t *)&ppkt->hdr, ppkt->pktSize);
m->pkt_len = ppkt->pktSize;
m->data_len = ppkt->pktSize;
pktgen_send_mbuf(m, pid, qid);
pktgen_set_q_flags(info, qid, DO_TX_FLUSH);
}
开发者ID:hanw,项目名称:pktgen-dpdk,代码行数:25,代码来源:pktgen-ipv4.c
示例16: __rte_hash_add_key_with_hash
static inline int32_t
__rte_hash_add_key_with_hash(const struct rte_hash *h,
const void *key, hash_sig_t sig)
{
hash_sig_t *sig_bucket;
uint8_t *key_bucket;
uint32_t bucket_index, i;
int32_t pos;
/* Get the hash signature and bucket index */
sig |= h->sig_msb;
bucket_index = sig & h->bucket_bitmask;
sig_bucket = get_sig_tbl_bucket(h, bucket_index);
key_bucket = get_key_tbl_bucket(h, bucket_index);
/* Check if key is already present in the hash */
for (i = 0; i < h->bucket_entries; i++) {
if ((sig == sig_bucket[i]) &&
likely(memcmp(key, get_key_from_bucket(h, key_bucket, i),
h->key_len) == 0)) {
return bucket_index * h->bucket_entries + i;
}
}
/* Check if any free slot within the bucket to add the new key */
pos = find_first(NULL_SIGNATURE, sig_bucket, h->bucket_entries);
if (unlikely(pos < 0))
return -ENOSPC;
/* Add the new key to the bucket */
sig_bucket[pos] = sig;
rte_memcpy(get_key_from_bucket(h, key_bucket, pos), key, h->key_len);
return bucket_index * h->bucket_entries + pos;
}
开发者ID:carriercomm,项目名称:dpdkv7,代码行数:35,代码来源:rte_hash.c
示例17: netdpcmd_ring_send
int netdpcmd_ring_send(void *buff, int buff_len)
{
void *msg;
if(buff_len > NETDP_RING_MSG_SIZE)
{
printf("Too long message size, max is %d \n", NETDP_RING_MSG_SIZE);
return NETDP_EMSGPOOL;
}
if (rte_mempool_get(netdpcmd_message_pool, &msg) < 0)
{
printf("Getting message failed \n");
return NETDP_EMSGPOOL;
}
rte_memcpy(msg, buff, buff_len);
if (rte_ring_enqueue(netdpcmd_ring_tx, msg) < 0)
{
printf("Sending message to NETDP stack failed \n");
rte_mempool_put(netdpcmd_message_pool, msg);
return NETDP_EMSGPOOL;
}
return 0;
}
开发者ID:aiyi,项目名称:dpdk-odp,代码行数:29,代码来源:netdpcmd_ring.c
示例18: send_paxos_message
static void
send_paxos_message(paxos_message *pm) {
uint8_t port_id = 0;
struct rte_mbuf *created_pkt = rte_pktmbuf_alloc(mbuf_pool);
created_pkt->l2_len = sizeof(struct ether_hdr);
created_pkt->l3_len = sizeof(struct ipv4_hdr);
created_pkt->l4_len = sizeof(struct udp_hdr) + sizeof(paxos_message);
craft_new_packet(&created_pkt, IPv4(192,168,4,99), ACCEPTOR_ADDR,
PROPOSER_PORT, ACCEPTOR_PORT, sizeof(paxos_message), port_id);
//struct udp_hdr *udp;
size_t udp_offset = sizeof(struct ether_hdr) + sizeof(struct ipv4_hdr);
//udp = rte_pktmbuf_mtod_offset(created_pkt, struct udp_hdr *, udp_offset);
size_t paxos_offset = udp_offset + sizeof(struct udp_hdr);
struct paxos_hdr *px = rte_pktmbuf_mtod_offset(created_pkt, struct paxos_hdr *, paxos_offset);
px->msgtype = rte_cpu_to_be_16(pm->type);
px->inst = rte_cpu_to_be_32(pm->u.accept.iid);
px->inst = rte_cpu_to_be_32(pm->u.accept.iid);
px->rnd = rte_cpu_to_be_16(pm->u.accept.ballot);
px->vrnd = rte_cpu_to_be_16(pm->u.accept.value_ballot);
px->acptid = 0;
rte_memcpy(px->paxosval, pm->u.accept.value.paxos_value_val, pm->u.accept.value.paxos_value_len);
created_pkt->ol_flags = PKT_TX_IPV4 | PKT_TX_IP_CKSUM | PKT_TX_UDP_CKSUM;
const uint16_t nb_tx = rte_eth_tx_burst(port_id, 0, &created_pkt, 1);
rte_pktmbuf_free(created_pkt);
rte_log(RTE_LOG_DEBUG, RTE_LOGTYPE_USER8, "Send %d messages\n", nb_tx);
}
开发者ID:usi-systems,项目名称:p4paxos,代码行数:26,代码来源:main.c
示例19: addr_sa_pton
int addr_sa_pton(const char* h, const char* s, struct sockaddr* sa, socklen_t slen) {
struct addrinfo hints;
struct addrinfo* ai;
memset(&hints, '\0', sizeof(hints));
hints.ai_flags = AI_NUMERICHOST;
if (h == NULL || getaddrinfo(h, s, &hints, &ai) != 0)
return (-1);
if (ai == NULL || ai->ai_addr == NULL) {
if (ai) { freeaddrinfo(ai); ai = NULL; }
return (-1);
}
if (sa != NULL) {
if (slen < ai->ai_addrlen) {
freeaddrinfo(ai);
return (-1);
}
rte_memcpy(sa, &ai->ai_addr, ai->ai_addrlen);
}
freeaddrinfo(ai);
return (0);
}
开发者ID:megahall,项目名称:sdn_sensor,代码行数:26,代码来源:netflow_addr.c
示例20: pktgen_packet_dump
void
pktgen_packet_dump(struct rte_mbuf *m, int pid)
{
port_info_t *info = &pktgen.info[pid];
int plen = (m->pkt_len + FCS_SIZE);
unsigned char *curr_data;
struct rte_mbuf *curr_mbuf;
/* Checking if info->dump_tail will not overflow is done in the caller */
if (info->dump_list[info->dump_tail].data != NULL)
rte_free(info->dump_list[info->dump_tail].data);
info->dump_list[info->dump_tail].data = rte_malloc("Packet data",
plen,
0);
info->dump_list[info->dump_tail].len = plen;
for (curr_data = info->dump_list[info->dump_tail].data, curr_mbuf = m;
curr_mbuf != NULL;
curr_data += curr_mbuf->data_len, curr_mbuf = curr_mbuf->next)
rte_memcpy(curr_data,
(uint8_t *)curr_mbuf->buf_addr + m->data_off,
curr_mbuf->data_len);
++info->dump_tail;
}
开发者ID:hemantagr,项目名称:pktgen-dpdk,代码行数:26,代码来源:pktgen-dump.c
注:本文中的rte_memcpy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论