[dpdk-dev] [PATCH v2] mbuf/ip_frag: Move mbuf chaining to common code
Ananyev, Konstantin
konstantin.ananyev at intel.com
Mon Sep 7 14:32:27 CEST 2015
Hi Simon,
Looks good to me, just one nit, see below.
Konstantin
> /**
> + * Chain an mbuf to another, thereby creating a segmented packet.
> + *
> + * @param head the head of the mbuf chain (the first packet)
> + * @param tail the mbuf to put last in the chain
> + *
> + * @return 0 on success, -EOVERFLOW if the chain is full (256 entries)
> + */
> +static inline int rte_pktmbuf_chain(struct rte_mbuf *head, struct rte_mbuf *tail)
> +{
> + struct rte_mbuf *cur_tail;
> +
> + /* Check for number-of-segments-overflow */
> + if (head->nb_segs + tail->nb_segs >= sizeof(head->nb_segs) << 8)
> + return -EOVERFLOW;
Would probably be better 'sizeof(head->nb_segs) << CHAR_BIT', or even just: ' > UINT8_MAX'.
Konstantin
> +
> + /* Chain 'tail' onto the old tail */
> + cur_tail = rte_pktmbuf_lastseg(head);
> + cur_tail->next = tail;
> +
> + /* accumulate number of segments and total length. */
> + head->nb_segs = (uint8_t)(head->nb_segs + tail->nb_segs);
> + head->pkt_len += tail->pkt_len;
> +
> + /* pkt_len is only set in the head */
> + tail->pkt_len = tail->data_len;
> +
> + return 0;
> +}
> +
> +/**
> * Dump an mbuf structure to the console.
> *
> * Dump all fields for the given packet mbuf and all its associated
> --
> 1.9.1
More information about the dev
mailing list