From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1BC1EA2EDB for ; Fri, 6 Sep 2019 08:54:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CB0B51F148; Fri, 6 Sep 2019 08:54:00 +0200 (CEST) Received: from rcdn-iport-5.cisco.com (rcdn-iport-5.cisco.com [173.37.86.76]) by dpdk.org (Postfix) with ESMTP id C456C1F148; Fri, 6 Sep 2019 08:53:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=6032; q=dns/txt; s=iport; t=1567752840; x=1568962440; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vCt5sLr7BuWD1KCrmUEDJhBUnptVkJXqdDvcw04+ITA=; b=B3r8shj7ey9ZPv3yMD0k1rvwyPiddYYgDKSigq/6O2GDW7DgtMIbsYl6 xzIIP5tYQTmrZlCEZAsZuxDRO0jKqAgcP24hwCKfcUemf0FUDnEkucmRm WKn6dHZ4Auk2QQu/6NUwtW/KARCn97BQ44xVbTlGamAxYai63xG6RCJ5e c=; X-IronPort-AV: E=Sophos;i="5.64,472,1559520000"; d="scan'208";a="406345198" Received: from rcdn-core-4.cisco.com ([173.37.93.155]) by rcdn-iport-5.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 06 Sep 2019 06:53:58 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by rcdn-core-4.cisco.com (8.15.2/8.15.2) with ESMTP id x866rwPK017170; Fri, 6 Sep 2019 06:53:58 GMT Received: by cisco.com (Postfix, from userid 508933) id 8FC7720F2003; Thu, 5 Sep 2019 23:53:58 -0700 (PDT) From: Hyong Youb Kim To: Ferruh Yigit Cc: dev@dpdk.org, John Daley , Dirk-Holger Lenz , Hyong Youb Kim , stable@dpdk.org Date: Thu, 5 Sep 2019 23:50:19 -0700 Message-Id: <20190906065020.21206-3-hyonkim@cisco.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190906065020.21206-1-hyonkim@cisco.com> References: <20190906065020.21206-1-hyonkim@cisco.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Outbound-SMTP-Client: 10.193.184.48, savbu-usnic-a.cisco.com X-Outbound-Node: rcdn-core-4.cisco.com Subject: [dpdk-dev] [PATCH 2/3] net/enic: fix two issues in probe for secondary process X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Only the primary process initializes the adapter private data and rte_eth_dev_data. For secondary processes, do not touch them. Secondary processes need to select the right Tx and Rx handlers. Pick the same handlers that the primary process uses. Fixes: fefed3d1e62c ("enic: new driver") Cc: stable@dpdk.org Reported-by: Dirk-Holger Lenz Signed-off-by: Hyong Youb Kim Tested-by: Dirk-Holger Lenz Reviewed-by: John Daley --- drivers/net/enic/enic.h | 5 ++++- drivers/net/enic/enic_ethdev.c | 10 ++++++++-- drivers/net/enic/enic_main.c | 28 ++++++++++++++++++++------- drivers/net/enic/enic_rxtx_vec_avx2.c | 5 ++--- 4 files changed, 35 insertions(+), 13 deletions(-) diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index 5a92508f0..2c8b3e0e4 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -134,6 +134,7 @@ struct enic { bool udp_rss_weak; /* Bodega style UDP RSS */ uint8_t ig_vlan_rewrite_mode; /* devargs ig-vlan-rewrite */ uint16_t vxlan_port; /* current vxlan port pushed to NIC */ + int use_simple_tx_handler; unsigned int flags; unsigned int priv_flags; @@ -333,7 +334,9 @@ uint16_t enic_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts); int enic_set_mtu(struct enic *enic, uint16_t new_mtu); int enic_link_update(struct enic *enic); -bool enic_use_vector_rx_handler(struct enic *enic); +bool enic_use_vector_rx_handler(struct rte_eth_dev *eth_dev); +void enic_pick_rx_handler(struct rte_eth_dev *eth_dev); +void enic_pick_tx_handler(struct rte_eth_dev *eth_dev); void enic_fdir_info(struct enic *enic); void enic_fdir_info_get(struct enic *enic, struct rte_eth_fdir_info *stats); extern const struct rte_flow_ops enic_flow_ops; diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c index 85d785e62..c6d0d7557 100644 --- a/drivers/net/enic/enic_ethdev.c +++ b/drivers/net/enic/enic_ethdev.c @@ -1216,12 +1216,18 @@ static int eth_enicpmd_dev_init(struct rte_eth_dev *eth_dev) ENICPMD_FUNC_TRACE(); - enic->port_id = eth_dev->data->port_id; - enic->rte_dev = eth_dev; eth_dev->dev_ops = &enicpmd_eth_dev_ops; eth_dev->rx_pkt_burst = &enic_recv_pkts; eth_dev->tx_pkt_burst = &enic_xmit_pkts; eth_dev->tx_pkt_prepare = &enic_prep_pkts; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { + enic_pick_tx_handler(eth_dev); + enic_pick_rx_handler(eth_dev); + return 0; + } + /* Only the primary sets up adapter and other data in shared memory */ + enic->port_id = eth_dev->data->port_id; + enic->rte_dev = eth_dev; /* Let rte_eth_dev_close() release the port resources */ eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE; diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 40af3781b..aecdee248 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -518,14 +518,14 @@ static void enic_prep_wq_for_simple_tx(struct enic *enic, uint16_t queue_idx) * used when that file is not compiled. */ __rte_weak bool -enic_use_vector_rx_handler(__rte_unused struct enic *enic) +enic_use_vector_rx_handler(__rte_unused struct rte_eth_dev *eth_dev) { return false; } -static void pick_rx_handler(struct enic *enic) +void enic_pick_rx_handler(struct rte_eth_dev *eth_dev) { - struct rte_eth_dev *eth_dev; + struct enic *enic = pmd_priv(eth_dev); /* * Preference order: @@ -533,8 +533,7 @@ static void pick_rx_handler(struct enic *enic) * 2. The non-scatter, simplified handler if scatter Rx is not used. * 3. The default handler as a fallback. */ - eth_dev = enic->rte_dev; - if (enic_use_vector_rx_handler(enic)) + if (enic_use_vector_rx_handler(eth_dev)) return; if (enic->rq_count > 0 && enic->rq[0].data_queue_enable == 0) { ENICPMD_LOG(DEBUG, " use the non-scatter Rx handler"); @@ -545,6 +544,20 @@ static void pick_rx_handler(struct enic *enic) } } +/* Secondary process uses this to set the Tx handler */ +void enic_pick_tx_handler(struct rte_eth_dev *eth_dev) +{ + struct enic *enic = pmd_priv(eth_dev); + + if (enic->use_simple_tx_handler) { + ENICPMD_LOG(DEBUG, " use the simple tx handler"); + eth_dev->tx_pkt_burst = &enic_simple_xmit_pkts; + } else { + ENICPMD_LOG(DEBUG, " use the default tx handler"); + eth_dev->tx_pkt_burst = &enic_xmit_pkts; + } +} + int enic_enable(struct enic *enic) { unsigned int index; @@ -622,12 +635,13 @@ int enic_enable(struct enic *enic) eth_dev->tx_pkt_burst = &enic_simple_xmit_pkts; for (index = 0; index < enic->wq_count; index++) enic_prep_wq_for_simple_tx(enic, index); + enic->use_simple_tx_handler = 1; } else { ENICPMD_LOG(DEBUG, " use the default tx handler"); eth_dev->tx_pkt_burst = &enic_xmit_pkts; } - pick_rx_handler(enic); + enic_pick_rx_handler(eth_dev); for (index = 0; index < enic->wq_count; index++) enic_start_wq(enic, index); @@ -1598,7 +1612,7 @@ int enic_set_mtu(struct enic *enic, uint16_t new_mtu) /* put back the real receive function */ rte_mb(); - pick_rx_handler(enic); + enic_pick_rx_handler(eth_dev); rte_mb(); /* restart Rx traffic */ diff --git a/drivers/net/enic/enic_rxtx_vec_avx2.c b/drivers/net/enic/enic_rxtx_vec_avx2.c index 517d4092f..36d4d0dea 100644 --- a/drivers/net/enic/enic_rxtx_vec_avx2.c +++ b/drivers/net/enic/enic_rxtx_vec_avx2.c @@ -806,12 +806,11 @@ enic_noscatter_vec_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, } bool -enic_use_vector_rx_handler(struct enic *enic) +enic_use_vector_rx_handler(struct rte_eth_dev *eth_dev) { - struct rte_eth_dev *eth_dev; + struct enic *enic = pmd_priv(eth_dev); struct rte_fdir_conf *fconf; - eth_dev = enic->rte_dev; /* User needs to request for the avx2 handler */ if (!enic->enable_avx2_rx) return false; -- 2.22.0