X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_mbuf%2Frte_mbuf.c;h=dc0467c96a2c8ee3a666d73e1eb937b332df30ac;hb=03600dd583af60c1cb454ee5e8e9f2118269545d;hp=d1f2a6f5655a2c7221c1b63aca164fc1db91dec6;hpb=b507905ff407f53ac87ec6c4a10a5f7000ecb062;p=dpdk.git diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c index d1f2a6f565..dc0467c96a 100644 --- a/lib/librte_mbuf/rte_mbuf.c +++ b/lib/librte_mbuf/rte_mbuf.c @@ -58,6 +58,7 @@ #include #include #include +#include /* * ctrlmbuf constructor, given as a callback function to @@ -119,17 +120,20 @@ rte_pktmbuf_init(struct rte_mempool *mp, __attribute__((unused)) unsigned i) { struct rte_mbuf *m = _m; - uint32_t mbuf_size, buf_len; + uint32_t mbuf_size, buf_len, priv_size; - mbuf_size = sizeof(struct rte_mbuf) + rte_pktmbuf_priv_size(mp); + priv_size = rte_pktmbuf_priv_size(mp); + mbuf_size = sizeof(struct rte_mbuf) + priv_size; buf_len = rte_pktmbuf_data_room_size(mp); + RTE_MBUF_ASSERT(RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) == priv_size); RTE_MBUF_ASSERT(mp->elt_size >= mbuf_size); RTE_MBUF_ASSERT(buf_len <= UINT16_MAX); memset(m, 0, mp->elt_size); - /* start of buffer is just after mbuf structure */ + /* start of buffer is after mbuf structure and priv data */ + m->priv_size = priv_size; m->buf_addr = (char *)m + mbuf_size; m->buf_physaddr = rte_mempool_virt2phy(mp, m) + mbuf_size; m->buf_len = (uint16_t)buf_len; @@ -143,6 +147,32 @@ rte_pktmbuf_init(struct rte_mempool *mp, m->port = 0xff; } +/* helper to create a mbuf pool */ +struct rte_mempool * +rte_pktmbuf_pool_create(const char *name, unsigned n, + unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, + int socket_id) +{ + struct rte_pktmbuf_pool_private mbp_priv; + unsigned elt_size; + + if (RTE_ALIGN(priv_size, RTE_MBUF_PRIV_ALIGN) != priv_size) { + RTE_LOG(ERR, MBUF, "mbuf priv_size=%u is not aligned\n", + priv_size); + rte_errno = EINVAL; + return NULL; + } + elt_size = sizeof(struct rte_mbuf) + (unsigned)priv_size + + (unsigned)data_room_size; + mbp_priv.mbuf_data_room_size = data_room_size; + mbp_priv.mbuf_priv_size = priv_size; + + return rte_mempool_create(name, n, elt_size, + cache_size, sizeof(struct rte_pktmbuf_pool_private), + rte_pktmbuf_pool_init, &mbp_priv, rte_pktmbuf_init, NULL, + socket_id, 0); +} + /* do some sanity checks on a mbuf: panic if it fails */ void rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header) @@ -223,19 +253,13 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask) case PKT_RX_FDIR: return "PKT_RX_FDIR"; case PKT_RX_L4_CKSUM_BAD: return "PKT_RX_L4_CKSUM_BAD"; case PKT_RX_IP_CKSUM_BAD: return "PKT_RX_IP_CKSUM_BAD"; - /* case PKT_RX_EIP_CKSUM_BAD: return "PKT_RX_EIP_CKSUM_BAD"; */ + case PKT_RX_EIP_CKSUM_BAD: return "PKT_RX_EIP_CKSUM_BAD"; /* case PKT_RX_OVERSIZE: return "PKT_RX_OVERSIZE"; */ /* case PKT_RX_HBUF_OVERFLOW: return "PKT_RX_HBUF_OVERFLOW"; */ /* case PKT_RX_RECIP_ERR: return "PKT_RX_RECIP_ERR"; */ /* case PKT_RX_MAC_ERR: return "PKT_RX_MAC_ERR"; */ - case PKT_RX_IPV4_HDR: return "PKT_RX_IPV4_HDR"; - case PKT_RX_IPV4_HDR_EXT: return "PKT_RX_IPV4_HDR_EXT"; - case PKT_RX_IPV6_HDR: return "PKT_RX_IPV6_HDR"; - case PKT_RX_IPV6_HDR_EXT: return "PKT_RX_IPV6_HDR_EXT"; case PKT_RX_IEEE1588_PTP: return "PKT_RX_IEEE1588_PTP"; case PKT_RX_IEEE1588_TMST: return "PKT_RX_IEEE1588_TMST"; - case PKT_RX_TUNNEL_IPV4_HDR: return "PKT_RX_TUNNEL_IPV4_HDR"; - case PKT_RX_TUNNEL_IPV6_HDR: return "PKT_RX_TUNNEL_IPV6_HDR"; default: return NULL; } }