[dpdk]struct rte_mbuf 结构

本文详细解析了DPDK库中的struct rte_mbuf结构,包括nb_segs表示的分段数量,pkt_len表示的总长度以及next字段用于访问后续分段信息。通过GDB调试展示了该结构的内存布局,揭示了如何存储超过MTU的报文。
摘要由CSDN通过智能技术生成

头文件 lib/librte_mbuf/rte_mbuf_core.h

20.11.3 版本下定义:

struct rte_mbuf {
    RTE_MARKER cacheline0;

    void *buf_addr;           /**< 段缓冲区的虚拟地址,即报文缓存区,注意默认前128个字节是预留的 */
    /**
     * 段缓冲区的物理地址。

     * 强制对齐到8字节,以确保32位和64位的mbuf cacheline0布局完全相同。

     * 这使得向量驱动程序的工作更容易。
     */
    rte_iova_t buf_iova __rte_aligned(sizeof(rte_iova_t));

    /* next 8 bytes are initialised on RX descriptor rearm */
    RTE_MARKER64 rearm_data;
    uint16_t data_off;   /**< 报文缓存偏移量,默认是128 */

    /**
     * 引用计数. 为了支持零拷贝广播,大小应当设置为16比特。
     * 它只能通过以下函数访问:
     * rte_mbuf_refcnt_update(), rte_mbuf_refcnt_read(), and
     * rte_mbuf_refcnt_set().  
     * 这些函数(原子或非原子)的功能由RTE_MBUF_REFCNT_ATOMIC 控制
     */
    uint16_t refcnt;
    uint16_t nb_segs;         /**< 分段数. */

    /** Input port (16 bits to support more than 256 virtual ports).
     * The event eth Tx adapter uses this field to specify the output port.
     */
    uint16_t port;

    uint64_t ol_flags;        /**< Offload features. */

    /* remaining bytes are set on RX when pulling packet from descriptor */
    RTE_MARKER rx_descriptor_fields1;

    /*
     * The packet type, which is the combination of outer/inner L2, L3, L4
     * and tunnel types. The packet_type is about data really present in the
     * mbuf. Example: if vlan stripping is enabled, a received vlan packet
     * would have RTE_PTYPE_L2_ETHER and not RTE_PTYPE_L2_VLAN because the
     * vlan is stripped from the data.
     */
    RTE_STD_C11
    union {
        uint32_t packet_type; /**< L2/L3/L4 and tunnel information. */
        __extension__
        struct {
            uint8_t l2_type:4;   /**< (Outer) L2 type. */
            uint8_t l3_type:4;   /**< (Outer) L3 type. */
            uint8_t l4_type:4;   /**< (Outer) L4 type. */
            uint8_t tun_type:4;  /**< Tunnel type. */
            RTE_STD_C11
            union {
                uint8_t inner_esp_next_proto;
                /**< ESP next protocol type, valid if
                 * RTE_PTYPE_TUNNEL_ESP tunnel type is set
                 * on both Tx an
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值