* Attach packet mbuf to another packet mbuf. * * If the mbuf we are attaching to isn't a direct buffer and is attached to * an external buffer, the mbuf being attached will be attached to the * external buffer instead of mbuf indirection. * * Otherwise, the mbuf will be indirectly attached. After attachment we * refer the mbuf we attached as 'indirect', while mbuf we attached to as * 'dire
| 1160 | * The packet mbuf we're attaching to. |
| 1161 | */ |
| 1162 | static inline void rte_pktmbuf_attach(struct rte_mbuf *mi, struct rte_mbuf *m) |
| 1163 | { |
| 1164 | RTE_ASSERT(RTE_MBUF_DIRECT(mi) && |
| 1165 | rte_mbuf_refcnt_read(mi) == 1); |
| 1166 | |
| 1167 | if (RTE_MBUF_HAS_EXTBUF(m)) { |
| 1168 | rte_mbuf_ext_refcnt_update(m->shinfo, 1); |
| 1169 | mi->ol_flags = m->ol_flags; |
| 1170 | mi->shinfo = m->shinfo; |
| 1171 | } else { |
| 1172 | /* if m is not direct, get the mbuf that embeds the data */ |
| 1173 | rte_mbuf_refcnt_update(rte_mbuf_from_indirect(m), 1); |
| 1174 | mi->priv_size = m->priv_size; |
| 1175 | mi->ol_flags = m->ol_flags | RTE_MBUF_F_INDIRECT; |
| 1176 | } |
| 1177 | |
| 1178 | __rte_pktmbuf_copy_hdr(mi, m); |
| 1179 | |
| 1180 | mi->data_off = m->data_off; |
| 1181 | mi->data_len = m->data_len; |
| 1182 | rte_mbuf_iova_set(mi, rte_mbuf_iova_get(m)); |
| 1183 | mi->buf_addr = m->buf_addr; |
| 1184 | mi->buf_len = m->buf_len; |
| 1185 | |
| 1186 | mi->next = NULL; |
| 1187 | mi->pkt_len = mi->data_len; |
| 1188 | mi->nb_segs = 1; |
| 1189 | |
| 1190 | __rte_mbuf_sanity_check(mi, 1); |
| 1191 | __rte_mbuf_sanity_check(m, 0); |
| 1192 | } |
| 1193 | |
| 1194 | /** |
| 1195 | * @internal used by rte_pktmbuf_detach(). |