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 1CFE86CD3 for ; Tue, 7 Jun 2016 08:13:00 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 06 Jun 2016 23:13:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,432,1459839600"; d="scan'208";a="970352222" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 06 Jun 2016 23:13:00 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id u576CvX5028953; Tue, 7 Jun 2016 14:12:57 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id u576Cr0k005565; Tue, 7 Jun 2016 14:12:55 +0800 Received: (from zhetao@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id u576Cr1o005561; Tue, 7 Jun 2016 14:12:53 +0800 From: Zhe Tao To: dev@dpdk.org Cc: wenzhuo.lu@intel.com, zhe.tao@intel.com, konstantin.ananyev@intel.com, bruce.richardson@intel.com, jing.d.chen@intel.com, cunming.liang@intel.com, jingjing.wu@intel.com, helin.zhang@intel.com Date: Tue, 7 Jun 2016 14:12:42 +0800 Message-Id: <1465279968-5515-3-git-send-email-zhe.tao@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1465279968-5515-1-git-send-email-zhe.tao@intel.com> References: <1465279968-5515-1-git-send-email-zhe.tao@intel.com> Subject: [dpdk-dev] [PATCH v3 2/8] lib/librte_ether: defind RX/TX lock mode 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, 07 Jun 2016 06:13:01 -0000 Define lock mode for RX/TX queue. Because when resetting the device we want the resetting thread to get the lock of the RX/TX queue to make sure the RX/TX is stopped. Using next ABI macro for this ABI change as it has too much impact. 7 APIs and 1 global variable are impacted. Signed-off-by: Wenzhuo Lu Signed-off-by: Zhe Tao --- lib/librte_ether/rte_ethdev.h | 62 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 74e895f..4efb5e9 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -354,7 +354,12 @@ struct rte_eth_rxmode { jumbo_frame : 1, /**< Jumbo Frame Receipt enable. */ hw_strip_crc : 1, /**< Enable CRC stripping by hardware. */ enable_scatter : 1, /**< Enable scatter packets rx handler */ +#ifndef RTE_NEXT_ABI enable_lro : 1; /**< Enable LRO */ +#else + enable_lro : 1, /**< Enable LRO */ + lock_mode : 1; /**< Using lock path */ +#endif }; /** @@ -634,11 +639,68 @@ struct rte_eth_txmode { /**< If set, reject sending out tagged pkts */ hw_vlan_reject_untagged : 1, /**< If set, reject sending out untagged pkts */ +#ifndef RTE_NEXT_ABI hw_vlan_insert_pvid : 1; /**< If set, enable port based VLAN insertion */ +#else + hw_vlan_insert_pvid : 1, + /**< If set, enable port based VLAN insertion */ + lock_mode : 1; + /**< If set, using lock path */ +#endif }; /** + * The macros for the RX/TX lock mode functions + */ +#ifdef RTE_NEXT_ABI +#define RX_LOCK_FUNCTION(dev, func) \ + (dev->data->dev_conf.rxmode.lock_mode ? \ + func ## _lock : func) + +#define TX_LOCK_FUNCTION(dev, func) \ + (dev->data->dev_conf.txmode.lock_mode ? \ + func ## _lock : func) +#else +#define RX_LOCK_FUNCTION(dev, func) func + +#define TX_LOCK_FUNCTION(dev, func) func +#endif + +/* Add the lock RX/TX function for VF reset */ +#define GENERATE_RX_LOCK(func, nic) \ +uint16_t func ## _lock(void *rx_queue, \ + struct rte_mbuf **rx_pkts, \ + uint16_t nb_pkts) \ +{ \ + struct nic ## _rx_queue *rxq = rx_queue; \ + uint16_t nb_rx = 0; \ + \ + if (rte_spinlock_trylock(&rxq->rx_lock)) { \ + nb_rx = func(rx_queue, rx_pkts, nb_pkts); \ + rte_spinlock_unlock(&rxq->rx_lock); \ + } \ + \ + return nb_rx; \ +} + +#define GENERATE_TX_LOCK(func, nic) \ +uint16_t func ## _lock(void *tx_queue, \ + struct rte_mbuf **tx_pkts, \ + uint16_t nb_pkts) \ +{ \ + struct nic ## _tx_queue *txq = tx_queue; \ + uint16_t nb_tx = 0; \ + \ + if (rte_spinlock_trylock(&txq->tx_lock)) { \ + nb_tx = func(tx_queue, tx_pkts, nb_pkts); \ + rte_spinlock_unlock(&txq->tx_lock); \ + } \ + \ + return nb_tx; \ +} + +/** * A structure used to configure an RX ring of an Ethernet port. */ struct rte_eth_rxconf { -- 2.1.4