From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 74E7F5A73 for ; Fri, 27 Mar 2015 14:23:35 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP; 27 Mar 2015 06:23:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,478,1422950400"; d="scan'208";a="671483592" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 27 Mar 2015 06:23:33 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t2RDNS93013928; Fri, 27 Mar 2015 21:23:32 +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 t2RDNOF3024129; Fri, 27 Mar 2015 21:23:27 +0800 Received: (from couyang@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t2RDNKmL024125; Fri, 27 Mar 2015 21:23:20 +0800 From: Ouyang Changchun To: dev@dpdk.org Date: Fri, 27 Mar 2015 21:23:15 +0800 Message-Id: <1427462595-23701-1-git-send-email-changchun.ouyang@intel.com> X-Mailer: git-send-email 1.7.12.2 In-Reply-To: <1427438150-6673-1-git-send-email-changchun.ouyang@intel.com> References: <1427438150-6673-1-git-send-email-changchun.ouyang@intel.com> Subject: [dpdk-dev] [PATCH v3] virtio: Fix crash issue for secondary process 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, 27 Mar 2015 13:23:36 -0000 It needs Rx function even in the case of secondary process, and it also needs check if it supports mergeable feature or not. Signed-off-by: Changchun Ouyang --- Changes in v3 -- Extract a function to remove the duplicated codes; Changes in v2: -- Check if it supports mergeable or not for the secondary process. lib/librte_pmd_virtio/virtio_ethdev.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/librte_pmd_virtio/virtio_ethdev.c b/lib/librte_pmd_virtio/virtio_ethdev.c index 603be2d..d462b9d 100644 --- a/lib/librte_pmd_virtio/virtio_ethdev.c +++ b/lib/librte_pmd_virtio/virtio_ethdev.c @@ -1097,6 +1097,16 @@ virtio_interrupt_handler(__rte_unused struct rte_intr_handle *handle, } +static void +rx_func_get(struct rte_eth_dev *eth_dev) +{ + struct virtio_hw *hw = eth_dev->data->dev_private; + if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF)) + eth_dev->rx_pkt_burst = &virtio_recv_mergeable_pkts; + else + eth_dev->rx_pkt_burst = &virtio_recv_pkts; +} + /* * This function is based on probe() function in virtio_pci.c * It returns 0 on success. @@ -1115,8 +1125,10 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) eth_dev->dev_ops = &virtio_eth_dev_ops; eth_dev->tx_pkt_burst = &virtio_xmit_pkts; - if (rte_eal_process_type() == RTE_PROC_SECONDARY) + if (rte_eal_process_type() == RTE_PROC_SECONDARY) { + rx_func_get(eth_dev); return 0; + } /* Allocate memory for storing MAC addresses */ eth_dev->data->mac_addrs = rte_zmalloc("virtio", ETHER_ADDR_LEN, 0); @@ -1144,14 +1156,13 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER); virtio_negotiate_features(hw); + rx_func_get(eth_dev); + /* Setting up rx_header size for the device */ - if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF)) { - eth_dev->rx_pkt_burst = &virtio_recv_mergeable_pkts; + if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF)) hw->vtnet_hdr_size = sizeof(struct virtio_net_hdr_mrg_rxbuf); - } else { - eth_dev->rx_pkt_burst = &virtio_recv_pkts; + else hw->vtnet_hdr_size = sizeof(struct virtio_net_hdr); - } /* Copy the permanent MAC address to: virtio_hw */ virtio_get_hwaddr(hw); -- 1.8.4.2