From: Intel Date: Wed, 19 Dec 2012 23:00:00 +0000 (+0100) Subject: mbuf: group fields in vlan_macip union X-Git-Tag: spdx-start~11379 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=42d7141686912f0c1541620f229c7281c1603121;p=dpdk.git mbuf: group fields in vlan_macip union Signed-off-by: Intel --- diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 16354aff61..b5bc5eb188 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -413,8 +413,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) } /* Combine the packet header write. VLAN is not consider here */ - mb->pkt.l2_len = l2_len; - mb->pkt.l3_len = l3_len; + mb->pkt.vlan_macip.f.l2_len = l2_len; + mb->pkt.vlan_macip.f.l3_len = l3_len; mb->ol_flags = ol_flags; } nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c index 0877f711d2..f25b768379 100644 --- a/app/test-pmd/macfwd.c +++ b/app/test-pmd/macfwd.c @@ -117,9 +117,9 @@ pkt_burst_mac_forward(struct fwd_stream *fs) ether_addr_copy(&ports[fs->tx_port].eth_addr, ð_hdr->s_addr); mb->ol_flags = txp->tx_ol_flags; - mb->pkt.l2_len = sizeof(struct ether_hdr); - mb->pkt.l3_len = sizeof(struct ipv4_hdr); - mb->pkt.vlan_tci = txp->tx_vlan_id; + mb->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr); + mb->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr); + mb->pkt.vlan_macip.f.vlan_tci = txp->tx_vlan_id; } nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_rx); fs->tx_packets += nb_tx; diff --git a/app/test-pmd/rxonly.c b/app/test-pmd/rxonly.c index 7f36ad98d5..8620839e7f 100644 --- a/app/test-pmd/rxonly.c +++ b/app/test-pmd/rxonly.c @@ -164,7 +164,8 @@ pkt_burst_receive(struct fwd_stream *fs) printf(" - FDIR hash=0x%x - FDIR id=0x%x ", mb->pkt.hash.fdir.hash, mb->pkt.hash.fdir.id); if (ol_flags & PKT_RX_VLAN_PKT) - printf(" - VLAN tci=0x%x", mb->pkt.vlan_tci); + printf(" - VLAN tci=0x%x", + mb->pkt.vlan_macip.f.vlan_tci); printf("\n"); if (ol_flags != 0) { int rxf; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index fa7b99a047..52caf496d2 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -331,9 +331,7 @@ testpmd_mbuf_ctor(struct rte_mempool *mp, mb->ol_flags = 0; mb->pkt.data = (char *) mb->buf_addr + RTE_PKTMBUF_HEADROOM; mb->pkt.nb_segs = 1; - mb->pkt.l2_len = 0; - mb->pkt.l3_len = 0; - mb->pkt.vlan_tci = 0; + mb->pkt.vlan_macip.data = 0; mb->pkt.hash.rss = 0; } diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 7692cb3d86..7f3b89ccb4 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -266,9 +266,9 @@ pkt_burst_transmit(struct fwd_stream *fs) pkt->pkt.nb_segs = tx_pkt_nb_segs; pkt->pkt.pkt_len = tx_pkt_length; pkt->ol_flags = ol_flags; - pkt->pkt.vlan_tci = vlan_tci; - pkt->pkt.l2_len = sizeof(struct ether_hdr); - pkt->pkt.l3_len = sizeof(struct ipv4_hdr); + pkt->pkt.vlan_macip.f.vlan_tci = vlan_tci; + pkt->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr); + pkt->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr); pkts_burst[nb_pkt] = pkt; } nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_pkt); diff --git a/examples/ipv4_frag/main.c b/examples/ipv4_frag/main.c index 2112d9f363..93daabff40 100644 --- a/examples/ipv4_frag/main.c +++ b/examples/ipv4_frag/main.c @@ -287,7 +287,7 @@ l3fwd_simple_forward(struct rte_mbuf *m, uint8_t port_in) rte_panic("No headroom in mbuf.\n"); } - m->pkt.l2_len = sizeof(struct ether_hdr); + m->pkt.vlan_macip.f.l2_len = sizeof(struct ether_hdr); ether_addr_copy(&remote_eth_addr, ð_hdr->d_addr); ether_addr_copy(&ports_eth_addr[port_out], ð_hdr->s_addr); diff --git a/examples/ipv4_frag/rte_ipv4_frag.h b/examples/ipv4_frag/rte_ipv4_frag.h index 76286d5836..5854e30538 100644 --- a/examples/ipv4_frag/rte_ipv4_frag.h +++ b/examples/ipv4_frag/rte_ipv4_frag.h @@ -239,7 +239,7 @@ static inline int32_t rte_ipv4_fragmentation(struct rte_mbuf *pkt_in, out_pkt->pkt.pkt_len - sizeof(struct ipv4_hdr)); out_pkt->ol_flags |= PKT_TX_IP_CKSUM; - out_pkt->pkt.l3_len = sizeof(struct ipv4_hdr); + out_pkt->pkt.vlan_macip.f.l3_len = sizeof(struct ipv4_hdr); /* Write the fragment to the output list */ pkts_out[out_pkt_pos] = out_pkt; diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c index 91625a4574..d1b1a66b3a 100644 --- a/examples/ipv4_multicast/main.c +++ b/examples/ipv4_multicast/main.c @@ -341,9 +341,7 @@ mcast_out_pkt(struct rte_mbuf *pkt, int use_clone) /* copy metadata from source packet*/ hdr->pkt.in_port = pkt->pkt.in_port; - hdr->pkt.vlan_tci = pkt->pkt.vlan_tci; - hdr->pkt.l2_len = pkt->pkt.l2_len; - hdr->pkt.l3_len = pkt->pkt.l3_len; + hdr->pkt.vlan_macip = pkt->pkt.vlan_macip; hdr->pkt.hash = pkt->pkt.hash; hdr->ol_flags = pkt->ol_flags; diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h index 88f6f33146..14e2f60c4b 100644 --- a/lib/librte_mbuf/rte_mbuf.h +++ b/lib/librte_mbuf/rte_mbuf.h @@ -115,12 +115,26 @@ struct rte_ctrlmbuf { */ #define PKT_TX_OFFLOAD_MASK (PKT_TX_VLAN_PKT | PKT_TX_IP_CKSUM | PKT_TX_L4_MASK) -/* Compare mask for vlan_macip_lens, used for context build up */ +/** Offload features */ +union rte_vlan_macip { + uint32_t data; + struct { + uint16_t l3_len:9; /**< L3 (IP) Header Length. */ + uint16_t l2_len:7; /**< L2 (MAC) Header Length. */ + uint16_t vlan_tci; + /**< VLAN Tag Control Identifier (CPU order). */ + } f; +}; + +/* + * Compare mask for vlan_macip_len.data, + * should be in sync with rte_vlan_macip.f layout. + * */ #define TX_VLAN_CMP_MASK 0xFFFF0000 /**< VLAN length - 16-bits. */ #define TX_MAC_LEN_CMP_MASK 0x0000FE00 /**< MAC length - 7-bits. */ #define TX_IP_LEN_CMP_MASK 0x000001FF /**< IP length - 9-bits. */ -/** MAC+IP length. */ -#define TX_MACIP_LEN_CMP_MASK (TX_MAC_LEN_CMP_MASK | TX_IP_LEN_CMP_MASK) +/**< MAC+IP length. */ +#define TX_MACIP_LEN_CMP_MASK (TX_MAC_LEN_CMP_MASK | TX_IP_LEN_CMP_MASK) /** * A packet message buffer. @@ -137,9 +151,7 @@ struct rte_pktmbuf { uint32_t pkt_len; /**< Total pkt len: sum of all segment data_len. */ /* offload features */ - uint16_t vlan_tci; /**< VLAN Tag Control Identifier (CPU order). */ - uint16_t l2_len:7; /**< L2 (MAC) Header Length. */ - uint16_t l3_len:9; /**< L3 (IP) Header Length. */ + union rte_vlan_macip vlan_macip; union { uint32_t rss; /**< RSS hash result if RSS enabled */ struct { @@ -543,9 +555,7 @@ static inline void rte_pktmbuf_reset(struct rte_mbuf *m) m->pkt.next = NULL; m->pkt.pkt_len = 0; - m->pkt.l2_len = 0; - m->pkt.l3_len = 0; - m->pkt.vlan_tci = 0; + m->pkt.vlan_macip.data = 0; m->pkt.nb_segs = 1; m->pkt.in_port = 0xff;