| 2033 | } |
| 2034 | |
| 2035 | int |
| 2036 | ff_dpdk_if_send(struct ff_dpdk_if_context *ctx, void *m, |
| 2037 | int total) |
| 2038 | { |
| 2039 | #ifdef FF_USE_PAGE_ARRAY |
| 2040 | struct lcore_conf *qconf = &lcore_conf; |
| 2041 | int len = 0; |
| 2042 | |
| 2043 | len = ff_if_send_onepkt(ctx, m,total); |
| 2044 | if (unlikely(len == MAX_PKT_BURST)) { |
| 2045 | send_burst(qconf, MAX_PKT_BURST, ctx->port_id); |
| 2046 | len = 0; |
| 2047 | } |
| 2048 | qconf->tx_mbufs[ctx->port_id].len = len; |
| 2049 | return 0; |
| 2050 | #endif |
| 2051 | struct rte_mempool *mbuf_pool = pktmbuf_pool[lcore_conf.socket_id]; |
| 2052 | struct rte_mbuf *head = rte_pktmbuf_alloc(mbuf_pool); |
| 2053 | if (head == NULL) { |
| 2054 | ff_traffic.tx_dropped++; |
| 2055 | ff_mbuf_free(m); |
| 2056 | return -1; |
| 2057 | } |
| 2058 | |
| 2059 | head->pkt_len = total; |
| 2060 | head->nb_segs = 0; |
| 2061 | |
| 2062 | int off = 0; |
| 2063 | struct rte_mbuf *cur = head, *prev = NULL; |
| 2064 | while(total > 0) { |
| 2065 | if (cur == NULL) { |
| 2066 | cur = rte_pktmbuf_alloc(mbuf_pool); |
| 2067 | if (cur == NULL) { |
| 2068 | ff_traffic.tx_dropped += head->nb_segs + 1; |
| 2069 | rte_pktmbuf_free(head); |
| 2070 | ff_mbuf_free(m); |
| 2071 | return -1; |
| 2072 | } |
| 2073 | } |
| 2074 | |
| 2075 | if (prev != NULL) { |
| 2076 | prev->next = cur; |
| 2077 | } |
| 2078 | head->nb_segs++; |
| 2079 | |
| 2080 | prev = cur; |
| 2081 | void *data = rte_pktmbuf_mtod(cur, void*); |
| 2082 | int len = total > RTE_MBUF_DEFAULT_DATAROOM ? RTE_MBUF_DEFAULT_DATAROOM : total; |
| 2083 | int ret = ff_mbuf_copydata(m, data, off, len); |
| 2084 | if (ret < 0) { |
| 2085 | ff_traffic.tx_dropped += head->nb_segs; |
| 2086 | rte_pktmbuf_free(head); |
| 2087 | ff_mbuf_free(m); |
| 2088 | return -1; |
| 2089 | } |
| 2090 | |
| 2091 | |
| 2092 | cur->data_len = len; |
no test coverage detected