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 A3535F90 for ; Tue, 24 Apr 2018 07:49:25 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Apr 2018 22:49:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,321,1520924400"; d="scan'208";a="35925690" Received: from dpdk06.sh.intel.com ([10.67.110.196]) by orsmga008.jf.intel.com with ESMTP; 23 Apr 2018 22:49:24 -0700 From: Jianfeng Tan To: dev@dpdk.org Cc: thomas@monjalon.net, Jianfeng Tan Date: Tue, 24 Apr 2018 05:51:24 +0000 Message-Id: <1524549084-139088-6-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1524549084-139088-1-git-send-email-jianfeng.tan@intel.com> References: <1520177405-59091-1-git-send-email-jianfeng.tan@intel.com> <1524549084-139088-1-git-send-email-jianfeng.tan@intel.com> Subject: [dpdk-dev] [PATCH v5 5/5] drivers/net: share vdev data to 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: , X-List-Received-Date: Tue, 24 Apr 2018 05:49:26 -0000 dpdk-procinfo, as a secondary process, cannot fetch stats for vdev. This patch enables that by attaching the port from the shared data. We also fill the eth dev ops, with only some ops works in secondary process, for example, stats_get(). Note that, we still cannot Rx/Tx packets on the ports which do not support multi-process. Reported-by: Signed-off-by: Vipin Varghese Signed-off-by: Jianfeng Tan Reviewed-by: Qi Zhang --- doc/guides/rel_notes/release_18_05.rst | 5 +++++ drivers/net/af_packet/rte_eth_af_packet.c | 17 +++++++++++++++-- drivers/net/bonding/rte_eth_bond_pmd.c | 13 +++++++++++++ drivers/net/failsafe/failsafe.c | 14 ++++++++++++++ drivers/net/kni/rte_eth_kni.c | 12 ++++++++++++ drivers/net/null/rte_eth_null.c | 13 +++++++++++++ drivers/net/octeontx/octeontx_ethdev.c | 14 ++++++++++++++ drivers/net/pcap/rte_eth_pcap.c | 13 +++++++++++++ drivers/net/softnic/rte_eth_softnic.c | 19 ++++++++++++++++--- drivers/net/tap/rte_eth_tap.c | 13 +++++++++++++ drivers/net/vhost/rte_eth_vhost.c | 17 +++++++++++++++-- 11 files changed, 143 insertions(+), 7 deletions(-) diff --git a/doc/guides/rel_notes/release_18_05.rst b/doc/guides/rel_notes/release_18_05.rst index 5276882..983c1c8 100644 --- a/doc/guides/rel_notes/release_18_05.rst +++ b/doc/guides/rel_notes/release_18_05.rst @@ -134,6 +134,11 @@ New Features Linux uevent is supported as backend of this device event notification framework. +* **Added support for procinfo and pdump on eth vdev.** + + For ethernet virtual devices (like tap, pcap, etc), with this feature, we can get + stats/xstats on shared memory from secondary process, and also pdump packets on + those virtual devices. API Changes ----------- diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 110e8a5..b394d3c 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -915,9 +915,22 @@ rte_pmd_af_packet_probe(struct rte_vdev_device *dev) int ret = 0; struct rte_kvargs *kvlist; int sockfd = -1; + struct rte_eth_dev *eth_dev; + const char *name = rte_vdev_device_name(dev); + + RTE_LOG(INFO, PMD, "Initializing pmd_af_packet for %s\n", name); - RTE_LOG(INFO, PMD, "Initializing pmd_af_packet for %s\n", - rte_vdev_device_name(dev)); + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + strlen(rte_vdev_device_args(dev)) == 0) { + eth_dev = rte_eth_dev_attach_secondary(name); + if (!eth_dev) { + RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); + return -1; + } + /* TODO: request info from primary to set up Rx and Tx */ + eth_dev->dev_ops = &ops; + return 0; + } kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments); if (kvlist == NULL) { diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 2805c71..09696ea 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -3021,6 +3021,7 @@ bond_probe(struct rte_vdev_device *dev) uint8_t bonding_mode, socket_id/*, agg_mode*/; int arg_count, port_id; uint8_t agg_mode; + struct rte_eth_dev *eth_dev; if (!dev) return -EINVAL; @@ -3028,6 +3029,18 @@ bond_probe(struct rte_vdev_device *dev) name = rte_vdev_device_name(dev); RTE_LOG(INFO, EAL, "Initializing pmd_bond for %s\n", name); + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + strlen(rte_vdev_device_args(dev)) == 0) { + eth_dev = rte_eth_dev_attach_secondary(name); + if (!eth_dev) { + RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); + return -1; + } + /* TODO: request info from primary to set up Rx and Tx */ + eth_dev->dev_ops = &default_dev_ops; + return 0; + } + kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), pmd_bond_init_valid_arguments); if (kvlist == NULL) diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index fa279cb..dc9b0d0 100644 --- a/drivers/net/failsafe/failsafe.c +++ b/drivers/net/failsafe/failsafe.c @@ -294,10 +294,24 @@ static int rte_pmd_failsafe_probe(struct rte_vdev_device *vdev) { const char *name; + struct rte_eth_dev *eth_dev; name = rte_vdev_device_name(vdev); INFO("Initializing " FAILSAFE_DRIVER_NAME " for %s", name); + + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + strlen(rte_vdev_device_args(vdev)) == 0) { + eth_dev = rte_eth_dev_attach_secondary(name); + if (!eth_dev) { + RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); + return -1; + } + /* TODO: request info from primary to set up Rx and Tx */ + eth_dev->dev_ops = &failsafe_ops; + return 0; + } + return fs_eth_dev_create(vdev); } diff --git a/drivers/net/kni/rte_eth_kni.c b/drivers/net/kni/rte_eth_kni.c index b7897b6..08fc6a3 100644 --- a/drivers/net/kni/rte_eth_kni.c +++ b/drivers/net/kni/rte_eth_kni.c @@ -404,6 +404,18 @@ eth_kni_probe(struct rte_vdev_device *vdev) params = rte_vdev_device_args(vdev); RTE_LOG(INFO, PMD, "Initializing eth_kni for %s\n", name); + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + strlen(params) == 0) { + eth_dev = rte_eth_dev_attach_secondary(name); + if (!eth_dev) { + RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); + return -1; + } + /* TODO: request info from primary to set up Rx and Tx */ + eth_dev->dev_ops = ð_kni_ops; + return 0; + } + ret = eth_kni_kvargs_process(&args, params); if (ret < 0) return ret; diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 7d89a32..6413a90 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -597,6 +597,7 @@ rte_pmd_null_probe(struct rte_vdev_device *dev) unsigned packet_size = default_packet_size; unsigned packet_copy = default_packet_copy; struct rte_kvargs *kvlist = NULL; + struct rte_eth_dev *eth_dev; int ret; if (!dev) @@ -606,6 +607,18 @@ rte_pmd_null_probe(struct rte_vdev_device *dev) params = rte_vdev_device_args(dev); RTE_LOG(INFO, PMD, "Initializing pmd_null for %s\n", name); + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + strlen(params) == 0) { + eth_dev = rte_eth_dev_attach_secondary(name); + if (!eth_dev) { + RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); + return -1; + } + /* TODO: request info from primary to set up Rx and Tx */ + eth_dev->dev_ops = &ops; + return 0; + } + if (params != NULL) { kvlist = rte_kvargs_parse(params, valid_arguments); if (kvlist == NULL) diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index ee06cd3..04120f5 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -1228,12 +1228,26 @@ octeontx_probe(struct rte_vdev_device *dev) struct rte_event_dev_config dev_conf; const char *eventdev_name = "event_octeontx"; struct rte_event_dev_info info; + struct rte_eth_dev *eth_dev; struct octeontx_vdev_init_params init_params = { OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT }; dev_name = rte_vdev_device_name(dev); + + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + strlen(rte_vdev_device_args(dev)) == 0) { + eth_dev = rte_eth_dev_attach_secondary(dev_name); + if (!eth_dev) { + RTE_LOG(ERR, PMD, "Failed to probe %s\n", dev_name); + return -1; + } + /* TODO: request info from primary to set up Rx and Tx */ + eth_dev->dev_ops = &octeontx_dev_ops; + return 0; + } + res = octeontx_parse_vdev_init_params(&init_params, dev); if (res < 0) return -EINVAL; diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 8740d52..570c9e9 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -898,6 +898,7 @@ pmd_pcap_probe(struct rte_vdev_device *dev) struct rte_kvargs *kvlist; struct pmd_devargs pcaps = {0}; struct pmd_devargs dumpers = {0}; + struct rte_eth_dev *eth_dev; int single_iface = 0; int ret; @@ -908,6 +909,18 @@ pmd_pcap_probe(struct rte_vdev_device *dev) start_cycles = rte_get_timer_cycles(); hz = rte_get_timer_hz(); + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + strlen(rte_vdev_device_args(dev)) == 0) { + eth_dev = rte_eth_dev_attach_secondary(name); + if (!eth_dev) { + RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); + return -1; + } + /* TODO: request info from primary to set up Rx and Tx */ + eth_dev->dev_ops = &ops; + return 0; + } + kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments); if (kvlist == NULL) return -1; diff --git a/drivers/net/softnic/rte_eth_softnic.c b/drivers/net/softnic/rte_eth_softnic.c index b0c1341..e324394 100644 --- a/drivers/net/softnic/rte_eth_softnic.c +++ b/drivers/net/softnic/rte_eth_softnic.c @@ -725,13 +725,26 @@ pmd_probe(struct rte_vdev_device *vdev) uint16_t hard_port_id; int numa_node; void *dev_private; + struct rte_eth_dev *eth_dev; + const char *name = rte_vdev_device_name(vdev); - RTE_LOG(INFO, PMD, - "Probing device \"%s\"\n", - rte_vdev_device_name(vdev)); + RTE_LOG(INFO, PMD, "Probing device \"%s\"\n", name); /* Parse input arguments */ params = rte_vdev_device_args(vdev); + + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + strlen(params) == 0) { + eth_dev = rte_eth_dev_attach_secondary(name); + if (!eth_dev) { + RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); + return -1; + } + /* TODO: request info from primary to set up Rx and Tx */ + eth_dev->dev_ops = &pmd_ops; + return 0; + } + if (!params) return -EINVAL; diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index b18efd8..cca5852 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -1721,6 +1721,7 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev) char tap_name[RTE_ETH_NAME_MAX_LEN]; char remote_iface[RTE_ETH_NAME_MAX_LEN]; struct ether_addr user_mac = { .addr_bytes = {0} }; + struct rte_eth_dev *eth_dev; tap_type = 1; strcpy(tuntap_name, "TAP"); @@ -1728,6 +1729,18 @@ rte_pmd_tap_probe(struct rte_vdev_device *dev) name = rte_vdev_device_name(dev); params = rte_vdev_device_args(dev); + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + strlen(params) == 0) { + eth_dev = rte_eth_dev_attach_secondary(name); + if (!eth_dev) { + RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); + return -1; + } + /* TODO: request info from primary to set up Rx and Tx */ + eth_dev->dev_ops = &ops; + return 0; + } + speed = ETH_SPEED_NUM_10G; snprintf(tap_name, sizeof(tap_name), "%s%d", DEFAULT_TAP_NAME, tap_unit++); diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index fea13eb..99a7727 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -1362,9 +1362,22 @@ rte_pmd_vhost_probe(struct rte_vdev_device *dev) int client_mode = 0; int dequeue_zero_copy = 0; int iommu_support = 0; + struct rte_eth_dev *eth_dev; + const char *name = rte_vdev_device_name(dev); + + RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n", name); - RTE_LOG(INFO, PMD, "Initializing pmd_vhost for %s\n", - rte_vdev_device_name(dev)); + if (rte_eal_process_type() == RTE_PROC_SECONDARY && + strlen(rte_vdev_device_args(dev)) == 0) { + eth_dev = rte_eth_dev_attach_secondary(name); + if (!eth_dev) { + RTE_LOG(ERR, PMD, "Failed to probe %s\n", name); + return -1; + } + /* TODO: request info from primary to set up Rx and Tx */ + eth_dev->dev_ops = &ops; + return 0; + } kvlist = rte_kvargs_parse(rte_vdev_device_args(dev), valid_arguments); if (kvlist == NULL) -- 2.7.4