From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by dpdk.org (Postfix) with ESMTP id 5B1E97F89 for ; Fri, 14 Nov 2014 17:53:53 +0100 (CET) Received: by mail-wi0-f173.google.com with SMTP id n3so43101wiv.12 for ; Fri, 14 Nov 2014 09:03:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IgP4IctIFMwJTtP3myPSTtE0E7Ep0wzeV79R4TT8N5g=; b=FBt0N53Tt9r81Et1PNiMa6yeQl/W2O0I+2w0A0qfVf8ozsPj9OVbOBWgl4DDp73anH Fo6XeWanUtrbk23qXgTZBHDhoMFFchc/UURbboTDm6LrFGhbltYFvI1WDAW4Trr+TnIG A/9w97MrWbIbF5nrzVtvmCEFUPVMJnDJhXtitXvZUfvauPFnyhsBndLB+DPSS2pTUIbF 28eelC2Ehqm9HktKOtHgPS5HJ161SFe25GH5snLrAIxobY+XBgs9tGBkeDhOX9IX5uz/ ubhO94E1MHgTp6R8tERZwsa2cpDc78HRCZCUpZGmlckK944SLtI6bapVG5iPDjnwoqID S55w== X-Gm-Message-State: ALoCoQljslO/EMlMwXhUXWIuyykw+Os+Aj0ihdcopykT5uvuomL079EvdfiRurM/nc/gCrKp9rn8 X-Received: by 10.180.19.234 with SMTP id i10mr9606053wie.28.1415984637299; Fri, 14 Nov 2014 09:03:57 -0800 (PST) Received: from glumotte.dev.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by mx.google.com with ESMTPSA id cu9sm40352554wjb.0.2014.11.14.09.03.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 14 Nov 2014 09:03:56 -0800 (PST) From: Olivier Matz To: dev@dpdk.org Date: Fri, 14 Nov 2014 18:03:23 +0100 Message-Id: <1415984609-2484-8-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1415984609-2484-1-git-send-email-olivier.matz@6wind.com> References: <1415635166-1364-1-git-send-email-olivier.matz@6wind.com> <1415984609-2484-1-git-send-email-olivier.matz@6wind.com> Cc: jigsaw@gmail.com Subject: [dpdk-dev] [PATCH v2 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: Fri, 14 Nov 2014 16:53:53 -0000 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 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. Signed-off-by: Olivier Matz --- 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(-) 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 |= PKT_TX_VLAN_PKT; + ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_INSERT_VLAN; ports[port_id].tx_vlan_id = vlan_id; } @@ -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 &= ~PKT_TX_VLAN_PKT; + ports[port_id].tx_ol_flags &= ~TESTPMD_TX_OFFLOAD_INSERT_VLAN; } 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 = 0; - if (tx_ol_flags & 0x1) { + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_IP_CKSUM) { /* HW checksum */ ol_flags |= PKT_TX_IP_CKSUM; } @@ -336,7 +336,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) if (l4_proto == IPPROTO_UDP) { udp_hdr = (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 |= PKT_TX_UDP_CKSUM; if (ipv4_tunnel) @@ -358,7 +358,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) uint16_t len; /* 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 |= PKT_TX_VXLAN_CKSUM; inner_l2_len = sizeof(struct ether_hdr); @@ -381,7 +381,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) unsigned char *) + len); inner_l4_proto = inner_ipv4_hdr->next_proto_id; - if (tx_ol_flags & 0x10) { + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_IP_CKSUM) { /* Do not delete, this is required by HW*/ inner_ipv4_hdr->hdr_checksum = 0; @@ -394,7 +394,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) unsigned char *) + len); inner_l4_proto = inner_ipv6_hdr->proto; } - if ((inner_l4_proto == IPPROTO_UDP) && (tx_ol_flags & 0x20)) { + if ((inner_l4_proto == IPPROTO_UDP) && + (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_UDP_CKSUM)) { /* HW Offload */ ol_flags |= PKT_TX_UDP_CKSUM; @@ -405,7 +406,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) else if (eth_type == ETHER_TYPE_IPv6) inner_udp_hdr->dgram_cksum = get_ipv6_psd_sum(inner_ipv6_hdr); - } else if ((inner_l4_proto == IPPROTO_TCP) && (tx_ol_flags & 0x40)) { + } else if ((inner_l4_proto == IPPROTO_TCP) && + (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_TCP_CKSUM)) { /* HW Offload */ ol_flags |= PKT_TX_TCP_CKSUM; inner_tcp_hdr = (struct tcp_hdr *) (rte_pktmbuf_mtod(mb, @@ -414,7 +416,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) inner_tcp_hdr->cksum = get_ipv4_psd_sum(inner_ipv4_hdr); else if (eth_type == ETHER_TYPE_IPv6) inner_tcp_hdr->cksum = get_ipv6_psd_sum(inner_ipv6_hdr); - } else if ((inner_l4_proto == IPPROTO_SCTP) && (tx_ol_flags & 0x80)) { + } else if ((inner_l4_proto == IPPROTO_SCTP) && + (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_SCTP_CKSUM)) { /* HW Offload */ ol_flags |= PKT_TX_SCTP_CKSUM; inner_sctp_hdr = (struct sctp_hdr *) (rte_pktmbuf_mtod(mb, @@ -427,7 +430,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) } else if (l4_proto == IPPROTO_TCP) { tcp_hdr = (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 |= PKT_TX_TCP_CKSUM; tcp_hdr->cksum = get_ipv4_psd_sum(ipv4_hdr); } @@ -440,7 +443,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) sctp_hdr = (struct sctp_hdr*) (rte_pktmbuf_mtod(mb, unsigned char *) + l2_len + l3_len); - if (tx_ol_flags & 0x8) { + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) { ol_flags |= PKT_TX_SCTP_CKSUM; sctp_hdr->cksum = 0; @@ -465,7 +468,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) if (l4_proto == IPPROTO_UDP) { udp_hdr = (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 |= PKT_TX_UDP_CKSUM; if (ipv6_tunnel) @@ -487,7 +490,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) uint16_t len; /* 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 |= PKT_TX_VXLAN_CKSUM; inner_l2_len = sizeof(struct ether_hdr); @@ -511,7 +514,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) inner_l4_proto = inner_ipv4_hdr->next_proto_id; /* HW offload */ - if (tx_ol_flags & 0x10) { + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_IP_CKSUM) { /* Do not delete, this is required by HW*/ inner_ipv4_hdr->hdr_checksum = 0; @@ -524,7 +527,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) inner_l4_proto = inner_ipv6_hdr->proto; } - if ((inner_l4_proto == IPPROTO_UDP) && (tx_ol_flags & 0x20)) { + if ((inner_l4_proto == IPPROTO_UDP) && + (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_UDP_CKSUM)) { inner_udp_hdr = (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 = get_ipv4_psd_sum(inner_ipv4_hdr); else if (eth_type == ETHER_TYPE_IPv6) inner_udp_hdr->dgram_cksum = get_ipv6_psd_sum(inner_ipv6_hdr); - } else if ((inner_l4_proto == IPPROTO_TCP) && (tx_ol_flags & 0x40)) { + } else if ((inner_l4_proto == IPPROTO_TCP) && + (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_TCP_CKSUM)) { /* HW offload */ ol_flags |= PKT_TX_TCP_CKSUM; inner_tcp_hdr = (struct tcp_hdr *) (rte_pktmbuf_mtod(mb, @@ -545,7 +550,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) else if (eth_type == ETHER_TYPE_IPv6) inner_tcp_hdr->cksum = get_ipv6_psd_sum(inner_ipv6_hdr); - } else if ((inner_l4_proto == IPPROTO_SCTP) && (tx_ol_flags & 0x80)) { + } else if ((inner_l4_proto == IPPROTO_SCTP) && + (tx_ol_flags & TESTPMD_TX_OFFLOAD_INNER_SCTP_CKSUM)) { /* HW offload */ ol_flags |= PKT_TX_SCTP_CKSUM; inner_sctp_hdr = (struct sctp_hdr *) (rte_pktmbuf_mtod(mb, @@ -559,7 +565,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) else if (l4_proto == IPPROTO_TCP) { tcp_hdr = (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 |= PKT_TX_TCP_CKSUM; tcp_hdr->cksum = get_ipv6_psd_sum(ipv6_hdr); } @@ -573,7 +579,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) sctp_hdr = (struct sctp_hdr*) (rte_pktmbuf_mtod(mb, unsigned char *) + l2_len + l3_len); - if (tx_ol_flags & 0x8) { + if (tx_ol_flags & TESTPMD_TX_OFFLOAD_SCTP_CKSUM) { ol_flags |= PKT_TX_SCTP_CKSUM; sctp_hdr->cksum = 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 = 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 += nb_rx; txp = &ports[fs->tx_port]; + if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_VLAN) + ol_flags = PKT_TX_VLAN_PKT; for (i = 0; i < nb_rx; i++) { mb = pkts_burst[i]; eth_hdr = 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 = txp->tx_ol_flags; + mb->ol_flags = ol_flags; mb->l2_len = sizeof(struct ether_hdr); mb->l3_len = sizeof(struct ipv4_hdr); mb->vlan_tci = 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 = 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 += nb_rx; txp = &ports[fs->tx_port]; + if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_VLAN) + ol_flags = PKT_TX_VLAN_PKT; for (i = 0; i < nb_rx; i++) { mb = pkts_burst[i]; eth_hdr = 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); - mb->ol_flags = txp->tx_ol_flags; + mb->ol_flags = ol_flags; mb->l2_len = sizeof(struct ether_hdr); mb->l3_len = sizeof(struct ipv4_hdr); mb->vlan_tci = 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 }; +/** 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_OFFLOAD...). */ 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 checksum */ 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 = 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 mbp = current_fwd_lcore()->mbp; - vlan_tci = ports[fs->tx_port].tx_vlan_id; - ol_flags = ports[fs->tx_port].tx_ol_flags; + txp = &ports[fs->tx_port]; + vlan_tci = txp->tx_vlan_id; + if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_VLAN) + ol_flags = PKT_TX_VLAN_PKT; for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) { pkt = tx_mbuf_alloc(mbp); if (pkt == NULL) { -- 2.1.0