From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 095742E81 for ; Tue, 25 Nov 2014 12:41:24 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 25 Nov 2014 03:52:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,455,1413270000"; d="scan'208";a="627928801" Received: from irsmsx109.ger.corp.intel.com ([163.33.3.23]) by fmsmga001.fm.intel.com with ESMTP; 25 Nov 2014 03:52:14 -0800 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.144]) by IRSMSX109.ger.corp.intel.com ([169.254.13.244]) with mapi id 14.03.0195.001; Tue, 25 Nov 2014 11:52:13 +0000 From: "Ananyev, Konstantin" To: Olivier Matz , "dev@dpdk.org" Thread-Topic: [PATCH v3 07/13] testpmd: fix use of offload flags in testpmd Thread-Index: AQHQBRW+ciDhvrannUaJM484Cuw+OZxxQe5w Date: Tue, 25 Nov 2014 11:52:12 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258213B9691@IRSMSX105.ger.corp.intel.com> References: <1415984609-2484-1-git-send-email-olivier.matz@6wind.com> <1416524335-22753-1-git-send-email-olivier.matz@6wind.com> <1416524335-22753-8-git-send-email-olivier.matz@6wind.com> In-Reply-To: <1416524335-22753-8-git-send-email-olivier.matz@6wind.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Cc: "jigsaw@gmail.com" Subject: Re: [dpdk-dev] [PATCH v3 07/13] testpmd: fix use of offload flags in testpmd X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Nov 2014 11:41:27 -0000 > -----Original Message----- > From: Olivier Matz [mailto:olivier.matz@6wind.com] > Sent: Thursday, November 20, 2014 10:59 PM > To: dev@dpdk.org > Cc: olivier.matz@6wind.com; Walukiewicz, Miroslaw; Liu, Jijiang; Liu, Yon= g; jigsaw@gmail.com; Richardson, Bruce; Ananyev, Konstantin > Subject: [PATCH v3 07/13] testpmd: fix use of offload flags in testpmd >=20 > In testpmd the rte_port->tx_ol_flags flag was used in 2 incompatible > manners: > - sometimes used with testpmd specific flags (0xff for checksums, and > bit 11 for vlan) > - sometimes assigned to m->ol_flags directly, which is wrong in case > of checksum flags >=20 > This commit replaces the hardcoded values by named definitions, which > are not compatible with mbuf flags. The testpmd forward engines are > fixed to use the flags properly. >=20 > Signed-off-by: Olivier Matz > --- Acked-by: Konstantin Ananyev > app/test-pmd/config.c | 4 ++-- > app/test-pmd/csumonly.c | 40 +++++++++++++++++++++++----------------- > app/test-pmd/macfwd.c | 5 ++++- > app/test-pmd/macswap.c | 5 ++++- > app/test-pmd/testpmd.h | 28 +++++++++++++++++++++------- > app/test-pmd/txonly.c | 9 ++++++--- > 6 files changed, 60 insertions(+), 31 deletions(-) >=20 > diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c > index b102b72..34b6fdb 100644 > --- a/app/test-pmd/config.c > +++ b/app/test-pmd/config.c > @@ -1670,7 +1670,7 @@ tx_vlan_set(portid_t port_id, uint16_t vlan_id) > return; > if (vlan_id_is_invalid(vlan_id)) > return; > - ports[port_id].tx_ol_flags |=3D PKT_TX_VLAN_PKT; > + ports[port_id].tx_ol_flags |=3D TESTPMD_TX_OFFLOAD_INSERT_VLAN; > ports[port_id].tx_vlan_id =3D vlan_id; > } >=20 > @@ -1679,7 +1679,7 @@ tx_vlan_reset(portid_t port_id) > { > if (port_id_is_invalid(port_id)) > return; > - ports[port_id].tx_ol_flags &=3D ~PKT_TX_VLAN_PKT; > + ports[port_id].tx_ol_flags &=3D ~TESTPMD_TX_OFFLOAD_INSERT_VLAN; > } >=20 > void > diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c > index 8d10bfd..743094a 100644 > --- a/app/test-pmd/csumonly.c > +++ b/app/test-pmd/csumonly.c > @@ -322,7 +322,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > /* Do not delete, this is required by HW*/ > ipv4_hdr->hdr_checksum =3D 0; >=20 > - if (tx_ol_flags & 0x1) { > + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) { > /* HW checksum */ > ol_flags |=3D PKT_TX_IP_CKSUM; > } > @@ -336,7 +336,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > if (l4_proto =3D=3D IPPROTO_UDP) { > udp_hdr =3D (struct udp_hdr*) (rte_pktmbuf_mtod(mb, > unsigned char *) + l2_len + l3_len); > - if (tx_ol_flags & 0x2) { > + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) { > /* HW Offload */ > ol_flags |=3D PKT_TX_UDP_CKSUM; > if (ipv4_tunnel) > @@ -358,7 +358,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > uint16_t len; >=20 > /* Check if inner L3/L4 checkum flag is set */ > - if (tx_ol_flags & 0xF0) > + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_CKSUM_MASK) > ol_flags |=3D PKT_TX_VXLAN_CKSUM; >=20 > inner_l2_len =3D sizeof(struct ether_hdr); > @@ -381,7 +381,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > unsigned char *) + len); > inner_l4_proto =3D inner_ipv4_hdr->next_proto_id; >=20 > - if (tx_ol_flags & 0x10) { > + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_IP_CKSUM) { >=20 > /* Do not delete, this is required by HW*/ > inner_ipv4_hdr->hdr_checksum =3D 0; > @@ -394,7 +394,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > unsigned char *) + len); > inner_l4_proto =3D inner_ipv6_hdr->proto; > } > - if ((inner_l4_proto =3D=3D IPPROTO_UDP) && (tx_ol_flags & 0x20)) { > + if ((inner_l4_proto =3D=3D IPPROTO_UDP) && > + (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_UDP_CKSUM)) { >=20 > /* HW Offload */ > ol_flags |=3D PKT_TX_UDP_CKSUM; > @@ -405,7 +406,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > else if (eth_type =3D=3D ETHER_TYPE_IPv6) > inner_udp_hdr->dgram_cksum =3D get_ipv6_psd_sum(inner_ipv6_hdr); >=20 > - } else if ((inner_l4_proto =3D=3D IPPROTO_TCP) && (tx_ol_flags & 0x= 40)) { > + } else if ((inner_l4_proto =3D=3D IPPROTO_TCP) && > + (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_TCP_CKSUM)) { > /* HW Offload */ > ol_flags |=3D PKT_TX_TCP_CKSUM; > inner_tcp_hdr =3D (struct tcp_hdr *) (rte_pktmbuf_mtod(mb, > @@ -414,7 +416,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > inner_tcp_hdr->cksum =3D get_ipv4_psd_sum(inner_ipv4_hdr); > else if (eth_type =3D=3D ETHER_TYPE_IPv6) > inner_tcp_hdr->cksum =3D get_ipv6_psd_sum(inner_ipv6_hdr); > - } else if ((inner_l4_proto =3D=3D IPPROTO_SCTP) && (tx_ol_flags & 0= x80)) { > + } else if ((inner_l4_proto =3D=3D IPPROTO_SCTP) && > + (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_SCTP_CKSUM)) { > /* HW Offload */ > ol_flags |=3D PKT_TX_SCTP_CKSUM; > inner_sctp_hdr =3D (struct sctp_hdr *) (rte_pktmbuf_mtod(mb, > @@ -427,7 +430,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > } else if (l4_proto =3D=3D IPPROTO_TCP) { > tcp_hdr =3D (struct tcp_hdr*) (rte_pktmbuf_mtod(mb, > unsigned char *) + l2_len + l3_len); > - if (tx_ol_flags & 0x4) { > + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) { > ol_flags |=3D PKT_TX_TCP_CKSUM; > tcp_hdr->cksum =3D get_ipv4_psd_sum(ipv4_hdr); > } > @@ -440,7 +443,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > sctp_hdr =3D (struct sctp_hdr*) (rte_pktmbuf_mtod(mb, > unsigned char *) + l2_len + l3_len); >=20 > - if (tx_ol_flags & 0x8) { > + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) { > ol_flags |=3D PKT_TX_SCTP_CKSUM; > sctp_hdr->cksum =3D 0; >=20 > @@ -465,7 +468,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > if (l4_proto =3D=3D IPPROTO_UDP) { > udp_hdr =3D (struct udp_hdr*) (rte_pktmbuf_mtod(mb, > unsigned char *) + l2_len + l3_len); > - if (tx_ol_flags & 0x2) { > + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_UDP_CKSUM) { > /* HW Offload */ > ol_flags |=3D PKT_TX_UDP_CKSUM; > if (ipv6_tunnel) > @@ -487,7 +490,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > uint16_t len; >=20 > /* Check if inner L3/L4 checksum flag is set */ > - if (tx_ol_flags & 0xF0) > + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_CKSUM_MASK) > ol_flags |=3D PKT_TX_VXLAN_CKSUM; >=20 > inner_l2_len =3D sizeof(struct ether_hdr); > @@ -511,7 +514,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > inner_l4_proto =3D inner_ipv4_hdr->next_proto_id; >=20 > /* HW offload */ > - if (tx_ol_flags & 0x10) { > + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_IP_CKSUM) { >=20 > /* Do not delete, this is required by HW*/ > inner_ipv4_hdr->hdr_checksum =3D 0; > @@ -524,7 +527,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > inner_l4_proto =3D inner_ipv6_hdr->proto; > } >=20 > - if ((inner_l4_proto =3D=3D IPPROTO_UDP) && (tx_ol_flags & 0x20)) { > + if ((inner_l4_proto =3D=3D IPPROTO_UDP) && > + (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_UDP_CKSUM)) { > inner_udp_hdr =3D (struct udp_hdr *) (rte_pktmbuf_mtod(mb, > unsigned char *) + len + inner_l3_len); > /* HW offload */ > @@ -534,7 +538,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > inner_udp_hdr->dgram_cksum =3D get_ipv4_psd_sum(inner_ipv4_hdr); > else if (eth_type =3D=3D ETHER_TYPE_IPv6) > inner_udp_hdr->dgram_cksum =3D get_ipv6_psd_sum(inner_ipv6_hdr); > - } else if ((inner_l4_proto =3D=3D IPPROTO_TCP) && (tx_ol_flags & 0x= 40)) { > + } else if ((inner_l4_proto =3D=3D IPPROTO_TCP) && > + (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_TCP_CKSUM)) { > /* HW offload */ > ol_flags |=3D PKT_TX_TCP_CKSUM; > inner_tcp_hdr =3D (struct tcp_hdr *) (rte_pktmbuf_mtod(mb, > @@ -545,7 +550,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > else if (eth_type =3D=3D ETHER_TYPE_IPv6) > inner_tcp_hdr->cksum =3D get_ipv6_psd_sum(inner_ipv6_hdr); >=20 > - } else if ((inner_l4_proto =3D=3D IPPROTO_SCTP) && (tx_ol_flags & 0= x80)) { > + } else if ((inner_l4_proto =3D=3D IPPROTO_SCTP) && > + (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_SCTP_CKSUM)) { > /* HW offload */ > ol_flags |=3D PKT_TX_SCTP_CKSUM; > inner_sctp_hdr =3D (struct sctp_hdr *) (rte_pktmbuf_mtod(mb, > @@ -559,7 +565,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > else if (l4_proto =3D=3D IPPROTO_TCP) { > tcp_hdr =3D (struct tcp_hdr*) (rte_pktmbuf_mtod(mb, > unsigned char *) + l2_len + l3_len); > - if (tx_ol_flags & 0x4) { > + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_TCP_CKSUM) { > ol_flags |=3D PKT_TX_TCP_CKSUM; > tcp_hdr->cksum =3D get_ipv6_psd_sum(ipv6_hdr); > } > @@ -573,7 +579,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) > sctp_hdr =3D (struct sctp_hdr*) (rte_pktmbuf_mtod(mb, > unsigned char *) + l2_len + l3_len); >=20 > - if (tx_ol_flags & 0x8) { > + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) { > ol_flags |=3D PKT_TX_SCTP_CKSUM; > sctp_hdr->cksum =3D 0; > /* Sanity check, only number of 4 bytes supported by HW */ > diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c > index 38bae23..aa3d705 100644 > --- a/app/test-pmd/macfwd.c > +++ b/app/test-pmd/macfwd.c > @@ -85,6 +85,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs) > uint16_t nb_rx; > uint16_t nb_tx; > uint16_t i; > + uint64_t ol_flags =3D 0; > #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES > uint64_t start_tsc; > uint64_t end_tsc; > @@ -108,6 +109,8 @@ pkt_burst_mac_forward(struct fwd_stream *fs) > #endif > fs->rx_packets +=3D nb_rx; > txp =3D &ports[fs->tx_port]; > + if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_VLAN) > + ol_flags =3D PKT_TX_VLAN_PKT; > for (i =3D 0; i < nb_rx; i++) { > mb =3D pkts_burst[i]; > eth_hdr =3D rte_pktmbuf_mtod(mb, struct ether_hdr *); > @@ -115,7 +118,7 @@ pkt_burst_mac_forward(struct fwd_stream *fs) > ð_hdr->d_addr); > ether_addr_copy(&ports[fs->tx_port].eth_addr, > ð_hdr->s_addr); > - mb->ol_flags =3D txp->tx_ol_flags; > + mb->ol_flags =3D ol_flags; > mb->l2_len =3D sizeof(struct ether_hdr); > mb->l3_len =3D sizeof(struct ipv4_hdr); > mb->vlan_tci =3D txp->tx_vlan_id; > diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c > index 1786095..ec61657 100644 > --- a/app/test-pmd/macswap.c > +++ b/app/test-pmd/macswap.c > @@ -85,6 +85,7 @@ pkt_burst_mac_swap(struct fwd_stream *fs) > uint16_t nb_rx; > uint16_t nb_tx; > uint16_t i; > + uint64_t ol_flags =3D 0; > #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES > uint64_t start_tsc; > uint64_t end_tsc; > @@ -108,6 +109,8 @@ pkt_burst_mac_swap(struct fwd_stream *fs) > #endif > fs->rx_packets +=3D nb_rx; > txp =3D &ports[fs->tx_port]; > + if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_VLAN) > + ol_flags =3D PKT_TX_VLAN_PKT; > for (i =3D 0; i < nb_rx; i++) { > mb =3D pkts_burst[i]; > eth_hdr =3D rte_pktmbuf_mtod(mb, struct ether_hdr *); > @@ -117,7 +120,7 @@ pkt_burst_mac_swap(struct fwd_stream *fs) > ether_addr_copy(ð_hdr->s_addr, ð_hdr->d_addr); > ether_addr_copy(&addr, ð_hdr->s_addr); >=20 > - mb->ol_flags =3D txp->tx_ol_flags; > + mb->ol_flags =3D ol_flags; > mb->l2_len =3D sizeof(struct ether_hdr); > mb->l3_len =3D sizeof(struct ipv4_hdr); > mb->vlan_tci =3D txp->tx_vlan_id; > diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h > index 9cbfeac..82af2bd 100644 > --- a/app/test-pmd/testpmd.h > +++ b/app/test-pmd/testpmd.h > @@ -123,14 +123,28 @@ struct fwd_stream { > #endif > }; >=20 > +/** Offload IP checksum in csum forward engine */ > +#define TESTPMD_TX_OFFLOAD_IP_CKSUM 0x0001 > +/** Offload UDP checksum in csum forward engine */ > +#define TESTPMD_TX_OFFLOAD_UDP_CKSUM 0x0002 > +/** Offload TCP checksum in csum forward engine */ > +#define TESTPMD_TX_OFFLOAD_TCP_CKSUM 0x0004 > +/** Offload SCTP checksum in csum forward engine */ > +#define TESTPMD_TX_OFFLOAD_SCTP_CKSUM 0x0008 > +/** Offload inner IP checksum in csum forward engine */ > +#define TESTPMD_TX_OFFLOAD_INNER_IP_CKSUM 0x0010 > +/** Offload inner UDP checksum in csum forward engine */ > +#define TESTPMD_TX_OFFLOAD_INNER_UDP_CKSUM 0x0020 > +/** Offload inner TCP checksum in csum forward engine */ > +#define TESTPMD_TX_OFFLOAD_INNER_TCP_CKSUM 0x0040 > +/** Offload inner SCTP checksum in csum forward engine */ > +#define TESTPMD_TX_OFFLOAD_INNER_SCTP_CKSUM 0x0080 > +/** Offload inner IP checksum mask */ > +#define TESTPMD_TX_OFFLOAD_INNER_CKSUM_MASK 0x00F0 > +/** Insert VLAN header in forward engine */ > +#define TESTPMD_TX_OFFLOAD_INSERT_VLAN 0x0100 > /** > * The data structure associated with each port. > - * tx_ol_flags is slightly different from ol_flags of rte_mbuf. > - * Bit 0: Insert IP checksum > - * Bit 1: Insert UDP checksum > - * Bit 2: Insert TCP checksum > - * Bit 3: Insert SCTP checksum > - * Bit 11: Insert VLAN Label > */ > struct rte_port { > struct rte_eth_dev_info dev_info; /**< PCI info + driver name */ > @@ -141,7 +155,7 @@ struct rte_port { > struct fwd_stream *rx_stream; /**< Port RX stream, if unique */ > struct fwd_stream *tx_stream; /**< Port TX stream, if unique */ > unsigned int socket_id; /**< For NUMA support */ > - uint64_t tx_ol_flags;/**< Offload Flags of TX packets. *= / > + uint16_t tx_ol_flags;/**< TX Offload Flags (TESTPMD_TX_O= FFLOAD...). */ > uint16_t tx_vlan_id; /**< Tag Id. in TX VLAN packets. */ > void *fwd_ctx; /**< Forwarding mode context */ > uint64_t rx_bad_ip_csum; /**< rx pkts with bad ip checks= um */ > diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c > index 3d08005..c984670 100644 > --- a/app/test-pmd/txonly.c > +++ b/app/test-pmd/txonly.c > @@ -196,6 +196,7 @@ static void > pkt_burst_transmit(struct fwd_stream *fs) > { > struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; > + struct rte_port *txp; > struct rte_mbuf *pkt; > struct rte_mbuf *pkt_seg; > struct rte_mempool *mbp; > @@ -203,7 +204,7 @@ pkt_burst_transmit(struct fwd_stream *fs) > uint16_t nb_tx; > uint16_t nb_pkt; > uint16_t vlan_tci; > - uint64_t ol_flags; > + uint64_t ol_flags =3D 0; > uint8_t i; > #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES > uint64_t start_tsc; > @@ -216,8 +217,10 @@ pkt_burst_transmit(struct fwd_stream *fs) > #endif >=20 > mbp =3D current_fwd_lcore()->mbp; > - vlan_tci =3D ports[fs->tx_port].tx_vlan_id; > - ol_flags =3D ports[fs->tx_port].tx_ol_flags; > + txp =3D &ports[fs->tx_port]; > + vlan_tci =3D txp->tx_vlan_id; > + if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_VLAN) > + ol_flags =3D PKT_TX_VLAN_PKT; > for (nb_pkt =3D 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) { > pkt =3D tx_mbuf_alloc(mbp); > if (pkt =3D=3D NULL) { > -- > 2.1.0