From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0103.outbound.protection.outlook.com [207.46.100.103]) by dpdk.org (Postfix) with ESMTP id 5D089C494 for ; Wed, 29 Jul 2015 09:38:51 +0200 (CEST) Received: from BY2PR03CA005.namprd03.prod.outlook.com (10.255.93.22) by BN3PR03MB1336.namprd03.prod.outlook.com (10.163.34.147) with Microsoft SMTP Server (TLS) id 15.1.225.19; Wed, 29 Jul 2015 07:38:49 +0000 Received: from BY2FFO11FD050.protection.gbl (10.255.93.4) by BY2PR03CA005.outlook.office365.com (10.255.93.22) with Microsoft SMTP Server (TLS) id 15.1.225.19 via Frontend Transport; Wed, 29 Jul 2015 07:38:49 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD050.mail.protection.outlook.com (10.1.15.187) with Microsoft SMTP Server (TLS) id 15.1.231.11 via Frontend Transport; Wed, 29 Jul 2015 07:38:49 +0000 Received: from localhost (rock.ap.freescale.net [10.193.20.106]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t6T7ckTg015933; Wed, 29 Jul 2015 00:38:46 -0700 From: To: Date: Wed, 29 Jul 2015 14:38:20 +0800 Message-ID: <1438151900-27849-1-git-send-email-xuelin.shi@freescale.com> X-Mailer: git-send-email 1.8.4 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD050; 1:U91+bVSOZIk7C1kS+umVmaDqT+hn0QbFc7ibL9WswuVLSrx4lWHJ/+oJQBazbXZO0r3vuCM+6vWSQusg6HBkAuN0RlqKgjqmImgVyBZ0SRnGnzN/kGO2tItxMo+6QyFhqxUFPKxBAQ0smparIc8xX8Me6LQQ2rvW+zrNxPkJgJYywW+wY27+AAsvjNu+R0KW2WVB+KkQ+6y85OSuzAlE9urovw57c3EZMqv6MR/qKljmmasGI86/3WmTk1Y8xARrqVRC2vil2dla2TNAj77pTDHTObMK8Zxvx0cbU+FMPF8U39lBwhZhV44P7qxUYF9NvJl1226sgMo1XQ+dRYu1Kw== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(339900001)(189002)(199003)(57986006)(110136002)(5001960100002)(19580395003)(86152002)(104016003)(19580405001)(86362001)(107886002)(85426001)(92566002)(62966003)(36756003)(105606002)(87936001)(47776003)(106466001)(33646002)(76506005)(77156002)(46102003)(189998001)(6806004)(2351001)(48376002)(229853001)(77096005)(50986999)(4001430100001); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR03MB1336; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB1336; 2:AwvswgB1/7Lq8GB6qtCQWsZUcGojplE0xq9kbRkKlR21zygF6u15ClU4tpxgEVKdvb5tAFxzwGCVpN9tJF9ehkbH+RQA9hxRdClJ5SKf4jWwxCqeB6Wejuzm1/Khy+Sdb6B0S9x8GDNBfnY0mGC/jUbyZFCg/Pr6tte+eLZnpNI=; 3:E6EgwfFTURkM/yIYn4XBbKo1vavwTsnTG/XFI3KFBJxOduDn9jgiHUVQH7k/gkwD+rleL1IXUvbgUtru+Z65GK/yttiDby4bisUBMYSRo1p0XwflGgDS5tk12qD6Rn0S4uJWc+yEfakVRGD39zs/7PaUZP3rabPylIF6lcPNkMQzuwYTENI6y5lQnDQOBaX3V93Sw0nvbpkzvvF0c8H1IQ3pgnwGhItQuPO6LjP6RRQ=; 25:9Z51iv7dJRcLyXAFmbeDw5rEscwURtJV8PERqOE5LxNJeBLRm+8yDfzUNCIk+ZFtJKA94txeux2vyrO8nWKGmxJ29XbbkRzPcgp2LBevVPvOuZFEsXbQRY+9rSP3nrrKnfRhMbihUh0alHl20plHjnlkckE3V6HANn54SLs6zOG6CCYGa88fJ9jRYwoqpZn2ABZBfww8SRzIp6PhfrZV5By9rNLuIUDby+uBuMONJfIRhFimHALNcDDn5HyMY2/y X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1336; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB1336; 20:jde4K4iVS8xsKyHhpsNJMIP0YVERJmB//fvG267W4R4khR+IQC2t1LrnmZkZTiZWCIMYz97KpSALZR3ttl5s95H18CQVk4QB5PQG8/JgIv6Da7OLHQ27kGaqF3Czott/xUd6iW6KgvXSfHkgCJxuGN78UFThe8FQM//xMTlAYUC9ZBugAx9dVKiNL4EXbXOG9TFBUbwJr3kZ2jrQ3LbnjrGaxDxCAD2aXYZpFCrXCWwiMSh79F+vofX4NVFlNzpADyC+7m91RRJPxjYZ4tLO6eX/CllfR6h97XqmPh4kpLM3kbtxfQN+g2inOyERrj5MGNCwEMpL1dYrB9GN3afLphNDJd6Z1P4CL/lc1ixKgto=; 4:WH8x+T6hIAEFAkbSd3++lYLv4bH1YE3iFgdy7HRC2FyV8ZIqXDxgxQhQmD9rD3NVPjgtnBt17lUDBmnFfutEe7aS1gHekBbcHmXG+16FWpTAfACpffv5Q2xZwKcEFRFZI3pg4jqv3FkPMbR+LHdxISANWJkwUIl16aYuKmsixm4XZmmXV07J9G0W8+V+/dxpki8t20BA9L+reIesE2+N3BI7QoW/EcPjAdJynubXKMclbb8ZxbSvEI4Wti1F/69ylu/kVOEaFCp+pQE39nwD8mNd4UoHuQvtcMfpN0UlZmU= BN3PR03MB1336: X-MS-Exchange-Organization-RulesExecuted X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-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CwkxA== X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB1336; 5:BTPa1txHPkXxrK0exvXmRcI/gGgBfG+QErCUPAgpkRGv9GCiPdNvPPNGKxn88r9clcRGJtHod04l98zjvRMUMuMKwP+mZ+rp1Iw4srfP/+P7cW74c/UhIHNBlmSP6Ns0AhTO53nmd+X2tG5MmcIXcg==; 24:DhGtUtXiDlAW74MoP/eG52bgztSZ4A53FJdfxKOjewo/goZqx/Sj0S9Y52/rxRIsETJraNO3V2cXz5ym7nPEHo1kPKoclVBruQIX6P6mCqo=; 20:YK++fXa5M9lle7hP8gqOd30y8NO60UH9Ju9HQnnYh0ubDC2qWLB+1dd5tTuC2C0DQaByM/kyzsu7b8WJ2Uo3BA== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jul 2015 07:38:49.0532 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1336 Cc: dev@dpdk.org, Xuelin Shi Subject: [dpdk-dev] [PATCH v4] ixgbe: fix data access on big endian cpu. 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: Wed, 29 Jul 2015 07:38:52 -0000 From: Xuelin Shi 1. cpu use data owned by ixgbe must use rte_le_to_cpu_xx(...) 2. cpu fill data to ixgbe must use rte_cpu_to_le_xx(...) 3. checking pci status with converted constant Signed-off-by: Xuelin Shi --- changes for v4: fix compiling error: cpu16 to cpu_16 fix issues reported by checkpatch drivers/net/ixgbe/ixgbe_rxtx.c | 78 ++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 26 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c index a7c94a9..f904b40 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx.c +++ b/drivers/net/ixgbe/ixgbe_rxtx.c @@ -130,7 +130,7 @@ ixgbe_tx_free_bufs(struct ixgbe_tx_queue *txq) /* check DD bit on threshold descriptor */ status = txq->tx_ring[txq->tx_next_dd].wb.status; - if (! (status & IXGBE_ADVTXD_STAT_DD)) + if (!(status & rte_cpu_to_le_32(IXGBE_ADVTXD_STAT_DD))) return 0; /* @@ -175,11 +175,14 @@ tx4(volatile union ixgbe_adv_tx_desc *txdp, struct rte_mbuf **pkts) pkt_len = (*pkts)->data_len; /* write data to descriptor */ - txdp->read.buffer_addr = buf_dma_addr; + txdp->read.buffer_addr = rte_cpu_to_le_64(buf_dma_addr); + txdp->read.cmd_type_len = - ((uint32_t)DCMD_DTYP_FLAGS | pkt_len); + rte_cpu_to_le_32((uint32_t)DCMD_DTYP_FLAGS | pkt_len); + txdp->read.olinfo_status = - (pkt_len << IXGBE_ADVTXD_PAYLEN_SHIFT); + rte_cpu_to_le_32(pkt_len << IXGBE_ADVTXD_PAYLEN_SHIFT); + rte_prefetch0(&(*pkts)->pool); } } @@ -195,11 +198,14 @@ tx1(volatile union ixgbe_adv_tx_desc *txdp, struct rte_mbuf **pkts) pkt_len = (*pkts)->data_len; /* write data to descriptor */ - txdp->read.buffer_addr = buf_dma_addr; + txdp->read.buffer_addr = rte_cpu_to_le_64(buf_dma_addr); + txdp->read.cmd_type_len = - ((uint32_t)DCMD_DTYP_FLAGS | pkt_len); + rte_cpu_to_le_32((uint32_t)DCMD_DTYP_FLAGS | pkt_len); + txdp->read.olinfo_status = - (pkt_len << IXGBE_ADVTXD_PAYLEN_SHIFT); + rte_cpu_to_le_32(pkt_len << IXGBE_ADVTXD_PAYLEN_SHIFT); + rte_prefetch0(&(*pkts)->pool); } @@ -511,6 +517,7 @@ ixgbe_xmit_cleanup(struct ixgbe_tx_queue *txq) uint16_t nb_tx_desc = txq->nb_tx_desc; uint16_t desc_to_clean_to; uint16_t nb_tx_to_clean; + uint32_t stat; /* Determine the last descriptor needing to be cleaned */ desc_to_clean_to = (uint16_t)(last_desc_cleaned + txq->tx_rs_thresh); @@ -519,7 +526,9 @@ ixgbe_xmit_cleanup(struct ixgbe_tx_queue *txq) /* Check to make sure the last descriptor to clean is done */ desc_to_clean_to = sw_ring[desc_to_clean_to].last_id; - if (! (txr[desc_to_clean_to].wb.status & IXGBE_TXD_STAT_DD)) + + stat = txr[desc_to_clean_to].wb.status; + if (!(stat & rte_cpu_to_le_32(IXGBE_TXD_STAT_DD))) { PMD_TX_FREE_LOG(DEBUG, "TX descriptor %4u is not done" @@ -806,12 +815,14 @@ ixgbe_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, */ slen = m_seg->data_len; buf_dma_addr = RTE_MBUF_DATA_DMA_ADDR(m_seg); + txd->read.buffer_addr = rte_cpu_to_le_64(buf_dma_addr); txd->read.cmd_type_len = rte_cpu_to_le_32(cmd_type_len | slen); txd->read.olinfo_status = rte_cpu_to_le_32(olinfo_status); + txe->last_id = tx_last; tx_id = txe->next_id; txe = txn; @@ -1062,14 +1073,16 @@ ixgbe_rx_scan_hw_ring(struct ixgbe_rx_queue *rxq) int s[LOOK_AHEAD], nb_dd; #endif /* RTE_NEXT_ABI */ int i, j, nb_rx = 0; + uint32_t stat; /* get references to current descriptor and S/W ring entry */ rxdp = &rxq->rx_ring[rxq->rx_tail]; rxep = &rxq->sw_ring[rxq->rx_tail]; + stat = rxdp->wb.upper.status_error; /* check to make sure there is at least 1 packet to receive */ - if (! (rxdp->wb.upper.status_error & IXGBE_RXDADV_STAT_DD)) + if (!(stat & rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD))) return 0; /* @@ -1081,7 +1094,7 @@ ixgbe_rx_scan_hw_ring(struct ixgbe_rx_queue *rxq) { /* Read desc statuses backwards to avoid race condition */ for (j = LOOK_AHEAD-1; j >= 0; --j) - s[j] = rxdp[j].wb.upper.status_error; + s[j] = rte_le_to_cpu_32(rxdp[j].wb.upper.status_error); #ifdef RTE_NEXT_ABI for (j = LOOK_AHEAD - 1; j >= 0; --j) @@ -1099,7 +1112,9 @@ ixgbe_rx_scan_hw_ring(struct ixgbe_rx_queue *rxq) /* Translate descriptor info to mbuf format */ for (j = 0; j < nb_dd; ++j) { mb = rxep[j].mbuf; - pkt_len = (uint16_t)(rxdp[j].wb.upper.length - rxq->crc_len); + pkt_len = rte_le_to_cpu_16(rxdp[j].wb.upper.length) - + rxq->crc_len; + mb->data_len = pkt_len; mb->pkt_len = pkt_len; mb->vlan_tci = rte_le_to_cpu_16(rxdp[j].wb.upper.vlan); @@ -1115,7 +1130,9 @@ ixgbe_rx_scan_hw_ring(struct ixgbe_rx_queue *rxq) ixgbe_rxd_pkt_info_to_pkt_type(pkt_info[j]); #else /* RTE_NEXT_ABI */ pkt_flags = rx_desc_hlen_type_rss_to_pkt_flags( - rxdp[j].wb.lower.lo_dword.data); + rte_le_to_cpu_32( + rxdp[j].wb.lower.lo_dword.data)); + /* reuse status field from scan list */ pkt_flags |= rx_desc_status_to_pkt_flags(s[j]); pkt_flags |= rx_desc_error_to_pkt_flags(s[j]); @@ -1123,12 +1140,16 @@ ixgbe_rx_scan_hw_ring(struct ixgbe_rx_queue *rxq) #endif /* RTE_NEXT_ABI */ if (likely(pkt_flags & PKT_RX_RSS_HASH)) - mb->hash.rss = rxdp[j].wb.lower.hi_dword.rss; + mb->hash.rss = rte_le_to_cpu_32( + rxdp[j].wb.lower.hi_dword.rss); + else if (pkt_flags & PKT_RX_FDIR) { - mb->hash.fdir.hash = - (uint16_t)((rxdp[j].wb.lower.hi_dword.csum_ip.csum) - & IXGBE_ATR_HASH_MASK); - mb->hash.fdir.id = rxdp[j].wb.lower.hi_dword.csum_ip.ip_id; + mb->hash.fdir.hash = rte_le_to_cpu_16( + rxdp[j].wb.lower.hi_dword.csum_ip.csum) & + IXGBE_ATR_HASH_MASK; + + mb->hash.fdir.id = rte_le_to_cpu_16( + rxdp[j].wb.lower.hi_dword.csum_ip.ip_id); } } @@ -1365,7 +1386,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, */ rxdp = &rx_ring[rx_id]; staterr = rxdp->wb.upper.status_error; - if (! (staterr & rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD))) + if (!(staterr & rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD))) break; rxd = *rxdp; @@ -1483,12 +1504,15 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, #endif /* RTE_NEXT_ABI */ if (likely(pkt_flags & PKT_RX_RSS_HASH)) - rxm->hash.rss = rxd.wb.lower.hi_dword.rss; + rxm->hash.rss = rte_le_to_cpu_32( + rxd.wb.lower.hi_dword.rss); else if (pkt_flags & PKT_RX_FDIR) { - rxm->hash.fdir.hash = - (uint16_t)((rxd.wb.lower.hi_dword.csum_ip.csum) - & IXGBE_ATR_HASH_MASK); - rxm->hash.fdir.id = rxd.wb.lower.hi_dword.csum_ip.ip_id; + rxm->hash.fdir.hash = rte_le_to_cpu_16( + rxd.wb.lower.hi_dword.csum_ip.csum) & + IXGBE_ATR_HASH_MASK; + + rxm->hash.fdir.id = rte_le_to_cpu_16( + rxd.wb.lower.hi_dword.csum_ip.ip_id); } /* * Store the mbuf address into the next entry of the array @@ -1998,7 +2022,7 @@ ixgbe_reset_tx_queue(struct ixgbe_tx_queue *txq) prev = (uint16_t) (txq->nb_tx_desc - 1); for (i = 0; i < txq->nb_tx_desc; i++) { volatile union ixgbe_adv_tx_desc *txd = &txq->tx_ring[i]; - txd->wb.status = IXGBE_TXD_STAT_DD; + txd->wb.status = rte_cpu_to_le_32(IXGBE_TXD_STAT_DD); txe[i].mbuf = NULL; txe[i].last_id = i; txe[prev].next_id = i; @@ -2604,7 +2628,8 @@ ixgbe_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) rxdp = &(rxq->rx_ring[rxq->rx_tail]); while ((desc < rxq->nb_rx_desc) && - (rxdp->wb.upper.status_error & IXGBE_RXDADV_STAT_DD)) { + (rxdp->wb.upper.status_error & + rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD))) { desc += IXGBE_RXQ_SCAN_INTERVAL; rxdp += IXGBE_RXQ_SCAN_INTERVAL; if (rxq->rx_tail + desc >= rxq->nb_rx_desc) @@ -2629,7 +2654,8 @@ ixgbe_dev_rx_descriptor_done(void *rx_queue, uint16_t offset) desc -= rxq->nb_rx_desc; rxdp = &rxq->rx_ring[desc]; - return !!(rxdp->wb.upper.status_error & IXGBE_RXDADV_STAT_DD); + return !!(rxdp->wb.upper.status_error & + rte_cpu_to_le_32(IXGBE_RXDADV_STAT_DD)); } void __attribute__((cold)) -- 1.9.1