From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f49.google.com (mail-wm0-f49.google.com [74.125.82.49]) by dpdk.org (Postfix) with ESMTP id 8594558DF for ; Thu, 17 Mar 2016 19:10:42 +0100 (CET) Received: by mail-wm0-f49.google.com with SMTP id p65so5528057wmp.0 for ; Thu, 17 Mar 2016 11:10:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sKuGIdEBhVIxlP8rKTAaPDDWTAzcaO4jJvNQEkF6CC4=; b=FlvNBQwL6NteqRtPO7sZwkZrqB/XiVIOQNKOJyGuhcoxiAsPbihaHCySZaOcuXXu4W olz3fJI3m6lxzl4P9/jOk6jkcDlzWJYnz/iBqyPRpp7gQsTxlR1WrPzKxNR6tzJK+wFy it+xmtWVNPY6pyXUNq2BexepNwnAvi9iuwB9XVTy0KToPsIxNhk80BVdEXSTgucIl8/2 u+rHe3XDmlDAe9Zd1+D5164kO/cFFUBHf60I70htBDyuP3YSB3ySnBEzqD1YFZW9auPm +VWwC9gguYqaUMn6IM9bu75ziQue+9Ta9feqBXlullHap1EIRVkNyFO1guzAXYjweN1K 1ETA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sKuGIdEBhVIxlP8rKTAaPDDWTAzcaO4jJvNQEkF6CC4=; b=M+xjNnycjZ/DUz6ageN/GUSkpS+W6c7N9PN6Vml7XdqTZ9pWht0f2I4IVw8uHVKWPg cd2qx7w6c16nkWqhXEcjLsDeVxDUI0t6IToGqE7Aji6Q81Vjl7cxiU5XkV9f7fLWXbzq 3rTlbWCb0ntUwz9rC+WgtaVf2I4DcF0BxsooTwYoGJR0Vsdrirkj8W1zenIj/d7GhHNn fn/O2XDOk0xwYPL675sjHYlT4mJ+XWHZL+bZinsJKDhTaoLRxQkvCa8RNeqmmGUZhjGq tn7r+wNoy8hXrtHAtJbKcIRYWZkAkRR2bitZDVjcIbmuCXyMltSjRdrzR5bI4J4uGAfI UEbQ== X-Gm-Message-State: AD7BkJI69tKujPnHz0A2sCVYRaR5qPechC+F2iscqg8lWZTk7x/nw1uhXzLbBSymSeB+cqpN X-Received: by 10.194.78.37 with SMTP id y5mr11449156wjw.78.1458238242379; Thu, 17 Mar 2016 11:10:42 -0700 (PDT) Received: from XPS13.localdomain (91.111.75.86.rev.sfr.net. [86.75.111.91]) by smtp.gmail.com with ESMTPSA id u14sm31196179wmu.8.2016.03.17.11.10.39 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 Mar 2016 11:10:41 -0700 (PDT) From: Thomas Monjalon To: marcdevel@gmail.com, bruce.richardson@intel.com, declan.doherty@intel.com, konstantin.ananyev@intel.com, wenzhuo.lu@intel.com, helin.zhang@intel.com, jing.d.chen@intel.com, harish.patil@qlogic.com, rahul.lakkireddy@chelsio.com, johndale@cisco.com, vido@cesnet.cz, adrien.mazarguil@6wind.com, alejandro.lucero@netronome.com Cc: dev@dpdk.org Date: Thu, 17 Mar 2016 19:08:58 +0100 Message-Id: <1458238145-7496-2-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1458238145-7496-1-git-send-email-thomas.monjalon@6wind.com> References: <1457992546-32230-1-git-send-email-thomas.monjalon@6wind.com> <1458238145-7496-1-git-send-email-thomas.monjalon@6wind.com> Subject: [dpdk-dev] [PATCH v11 1/8] ethdev: use constants for link state 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: Thu, 17 Mar 2016 18:10:42 -0000 Define and use ETH_LINK_UP and ETH_LINK_DOWN where appropriate. Signed-off-by: Marc Sune Signed-off-by: Thomas Monjalon --- app/test-pipeline/init.c | 2 +- app/test-pmd/testpmd.c | 2 +- app/test/test_pmd_perf.c | 2 +- app/test/virtual_pmd.c | 6 +++--- drivers/net/af_packet/rte_eth_af_packet.c | 6 +++--- drivers/net/bnx2x/bnx2x_ethdev.c | 2 +- drivers/net/bnx2x/elink.c | 2 +- drivers/net/bonding/rte_eth_bond_api.c | 4 ++-- drivers/net/bonding/rte_eth_bond_pmd.c | 12 ++++++------ drivers/net/e1000/em_ethdev.c | 8 ++++---- drivers/net/e1000/igb_ethdev.c | 4 ++-- drivers/net/fm10k/fm10k_ethdev.c | 2 +- drivers/net/i40e/i40e_ethdev_vf.c | 2 +- drivers/net/ixgbe/ixgbe_ethdev.c | 4 ++-- drivers/net/mpipe/mpipe_tilegx.c | 12 ++++++------ drivers/net/nfp/nfp_net.c | 2 +- drivers/net/null/rte_eth_null.c | 6 +++--- drivers/net/pcap/rte_eth_pcap.c | 6 +++--- drivers/net/ring/rte_eth_ring.c | 10 +++++----- drivers/net/szedata2/rte_eth_szedata2.c | 2 +- drivers/net/virtio/virtio_ethdev.c | 6 +++--- drivers/net/vmxnet3/vmxnet3_ethdev.c | 2 +- drivers/net/xenvirt/rte_eth_xenvirt.c | 6 +++--- examples/exception_path/main.c | 2 +- examples/ip_fragmentation/main.c | 2 +- examples/ip_pipeline/init.c | 2 +- examples/ip_reassembly/main.c | 2 +- examples/ipsec-secgw/ipsec-secgw.c | 2 +- examples/ipv4_multicast/main.c | 2 +- examples/kni/main.c | 2 +- examples/l2fwd-crypto/main.c | 2 +- examples/l2fwd-ivshmem/host/host.c | 2 +- examples/l2fwd-jobstats/main.c | 2 +- examples/l2fwd-keepalive/main.c | 2 +- examples/l2fwd/main.c | 2 +- examples/l3fwd-acl/main.c | 2 +- examples/l3fwd-power/main.c | 2 +- examples/l3fwd/main.c | 2 +- examples/link_status_interrupt/main.c | 2 +- examples/load_balancer/init.c | 2 +- examples/multi_process/client_server_mp/mp_server/init.c | 2 +- examples/multi_process/l2fwd_fork/main.c | 2 +- examples/multi_process/symmetric_mp/main.c | 2 +- examples/performance-thread/l3fwd-thread/main.c | 2 +- lib/librte_ether/rte_ethdev.h | 5 ++++- 45 files changed, 80 insertions(+), 77 deletions(-) diff --git a/app/test-pipeline/init.c b/app/test-pipeline/init.c index db2196b..aef082f 100644 --- a/app/test-pipeline/init.c +++ b/app/test-pipeline/init.c @@ -205,7 +205,7 @@ app_ports_check_link(void) link.link_speed / 1000, link.link_status ? "UP" : "DOWN"); - if (link.link_status == 0) + if (link.link_status == ETH_LINK_DOWN) all_ports_up = 0; } diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 38b9051..f713f39 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -1641,7 +1641,7 @@ check_all_ports_link_status(uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c index 48e16c9..59803f7 100644 --- a/app/test/test_pmd_perf.c +++ b/app/test/test_pmd_perf.c @@ -192,7 +192,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c index a538c8a..b1d40d7 100644 --- a/app/test/virtual_pmd.c +++ b/app/test/virtual_pmd.c @@ -79,7 +79,7 @@ static void virtual_ethdev_stop(struct rte_eth_dev *eth_dev __rte_unused) void *pkt = NULL; struct virtual_ethdev_private *prv = eth_dev->data->dev_private; - eth_dev->data->dev_link.link_status = 0; + eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; eth_dev->data->dev_started = 0; while (rte_ring_dequeue(prv->rx_queue, &pkt) != -ENOENT) rte_pktmbuf_free(pkt); @@ -199,7 +199,7 @@ virtual_ethdev_link_update_success(struct rte_eth_dev *bonded_eth_dev, int wait_to_complete __rte_unused) { if (!bonded_eth_dev->data->dev_started) - bonded_eth_dev->data->dev_link.link_status = 0; + bonded_eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; return 0; } @@ -603,7 +603,7 @@ virtual_ethdev_create(const char *name, struct ether_addr *mac_addr, TAILQ_INIT(&(eth_dev->link_intr_cbs)); - eth_dev->data->dev_link.link_status = 0; + eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; eth_dev->data->dev_link.link_speed = ETH_LINK_SPEED_10000; eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX; diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 5544528..dee7b59 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -118,7 +118,7 @@ static const char *drivername = "AF_PACKET PMD"; static struct rte_eth_link pmd_link = { .link_speed = 10000, .link_duplex = ETH_LINK_FULL_DUPLEX, - .link_status = 0 + .link_status = ETH_LINK_DOWN, }; static uint16_t @@ -234,7 +234,7 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) static int eth_dev_start(struct rte_eth_dev *dev) { - dev->data->dev_link.link_status = 1; + dev->data->dev_link.link_status = ETH_LINK_UP; return 0; } @@ -257,7 +257,7 @@ eth_dev_stop(struct rte_eth_dev *dev) close(sockfd); } - dev->data->dev_link.link_status = 0; + dev->data->dev_link.link_status = ETH_LINK_DOWN; } static int diff --git a/drivers/net/bnx2x/bnx2x_ethdev.c b/drivers/net/bnx2x/bnx2x_ethdev.c index fe8cfd0..dc9ce84 100644 --- a/drivers/net/bnx2x/bnx2x_ethdev.c +++ b/drivers/net/bnx2x/bnx2x_ethdev.c @@ -266,7 +266,7 @@ bnx2xvf_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_comple if (sc->old_bulletin.valid_bitmap & (1 << CHANNEL_DOWN)) { PMD_DRV_LOG(ERR, "PF indicated channel is down." "VF device is no longer operational"); - dev->data->dev_link.link_status = 0; + dev->data->dev_link.link_status = ETH_LINK_DOWN; } return old_link_status == dev->data->dev_link.link_status ? -1 : 0; diff --git a/drivers/net/bnx2x/elink.c b/drivers/net/bnx2x/elink.c index da2366e..b9149b8 100644 --- a/drivers/net/bnx2x/elink.c +++ b/drivers/net/bnx2x/elink.c @@ -6312,7 +6312,7 @@ elink_status_t elink_link_update(struct elink_params * params, for (phy_index = ELINK_INT_PHY; phy_index < params->num_phys; phy_index++) { phy_vars[phy_index].flow_ctrl = 0; - phy_vars[phy_index].link_status = 0; + phy_vars[phy_index].link_status = ETH_LINK_DOWN; phy_vars[phy_index].line_speed = 0; phy_vars[phy_index].duplex = DUPLEX_FULL; phy_vars[phy_index].phy_link_up = 0; diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c index 3fca764..718e443 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -205,7 +205,7 @@ rte_eth_bond_create(const char *name, uint8_t mode, uint8_t socket_id) TAILQ_INIT(&(eth_dev->link_intr_cbs)); - eth_dev->data->dev_link.link_status = 0; + eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; eth_dev->data->mac_addrs = rte_zmalloc_socket(name, ETHER_ADDR_LEN, 0, socket_id); @@ -419,7 +419,7 @@ __eth_bond_slave_add_lock_free(uint8_t bonded_port_id, uint8_t slave_port_id) if (bonded_eth_dev->data->dev_started) { rte_eth_link_get_nowait(slave_port_id, &link_props); - if (link_props.link_status == 1) { + if (link_props.link_status == ETH_LINK_UP) { if (internals->active_slave_count == 0 && !internals->user_defined_primary_port) bond_ethdev_primary_set(internals, diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 011150a..66d0856 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -1500,7 +1500,7 @@ bond_ethdev_start(struct rte_eth_dev *eth_dev) return -1; } - eth_dev->data->dev_link.link_status = 0; + eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; eth_dev->data->dev_started = 1; internals = eth_dev->data->dev_private; @@ -1617,7 +1617,7 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev) internals->active_slave_count = 0; internals->link_status_polling_enabled = 0; - eth_dev->data->dev_link.link_status = 0; + eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; eth_dev->data->dev_started = 0; } @@ -1783,7 +1783,7 @@ bond_ethdev_link_update(struct rte_eth_dev *bonded_eth_dev, if (!bonded_eth_dev->data->dev_started || internals->active_slave_count == 0) { - bonded_eth_dev->data->dev_link.link_status = 0; + bonded_eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; return 0; } else { struct rte_eth_dev *slave_eth_dev; @@ -1794,7 +1794,7 @@ bond_ethdev_link_update(struct rte_eth_dev *bonded_eth_dev, (*slave_eth_dev->dev_ops->link_update)(slave_eth_dev, wait_to_complete); - if (slave_eth_dev->data->dev_link.link_status == 1) { + if (slave_eth_dev->data->dev_link.link_status == ETH_LINK_UP) { link_up = 1; break; } @@ -1963,7 +1963,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type, /* if no active slave ports then set this port to be primary port */ if (internals->active_slave_count < 1) { /* If first active slave, then change link status */ - bonded_eth_dev->data->dev_link.link_status = 1; + bonded_eth_dev->data->dev_link.link_status = ETH_LINK_UP; internals->current_primary_port = port_id; lsc_flag = 1; @@ -1991,7 +1991,7 @@ bond_ethdev_lsc_event_callback(uint8_t port_id, enum rte_eth_event_type type, * link properties */ if (internals->active_slave_count < 1) { lsc_flag = 1; - bonded_eth_dev->data->dev_link.link_status = 0; + bonded_eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; link_properties_reset(bonded_eth_dev); } diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c index a8c26ed..58093c6 100644 --- a/drivers/net/e1000/em_ethdev.c +++ b/drivers/net/e1000/em_ethdev.c @@ -1102,14 +1102,14 @@ eth_em_link_update(struct rte_eth_dev *dev, int wait_to_complete) old = link; /* Now we check if a transition has happened */ - if (link_check && (link.link_status == 0)) { + if (link_check && (link.link_status == ETH_LINK_DOWN)) { hw->mac.ops.get_link_up_info(hw, &link.link_speed, &link.link_duplex); - link.link_status = 1; - } else if (!link_check && (link.link_status == 1)) { + link.link_status = ETH_LINK_UP; + } else if (!link_check && (link.link_status == ETH_LINK_UP)) { link.link_speed = 0; link.link_duplex = 0; - link.link_status = 0; + link.link_status = ETH_LINK_DOWN; } rte_em_dev_atomic_write_link_status(dev, &link); diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c index 9a34d01..311f866 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -2030,11 +2030,11 @@ eth_igb_link_update(struct rte_eth_dev *dev, int wait_to_complete) if (link_check) { hw->mac.ops.get_link_up_info(hw, &link.link_speed, &link.link_duplex); - link.link_status = 1; + link.link_status = ETH_LINK_UP; } else if (!link_check) { link.link_speed = 0; link.link_duplex = 0; - link.link_status = 0; + link.link_status = ETH_LINK_DOWN; } rte_igb_dev_atomic_write_link_status(dev, &link); diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index 4b07a8b..edc8c11 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -1249,7 +1249,7 @@ fm10k_link_update(struct rte_eth_dev *dev, * is no 50Gbps Ethernet. */ dev->data->dev_link.link_speed = 0; dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX; - dev->data->dev_link.link_status = 1; + dev->data->dev_link.link_status = ETH_LINK_UP; return 0; } diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c index 6b7b350..de00aff 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -1959,7 +1959,7 @@ i40evf_dev_link_update(struct rte_eth_dev *dev, /* Always assume it's up, for Linux driver PF host */ new_link.link_duplex = ETH_LINK_AUTONEG_DUPLEX; new_link.link_speed = ETH_LINK_SPEED_10000; - new_link.link_status = 1; + new_link.link_status = ETH_LINK_UP; } i40evf_dev_atomic_write_link_status(dev, &new_link); diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 5371720..be28f7e 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -2995,7 +2995,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) int link_up; int diag; - link.link_status = 0; + link.link_status = ETH_LINK_DOWN; link.link_speed = 0; link.link_duplex = 0; memset(&old, 0, sizeof(old)); @@ -3024,7 +3024,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) return -1; return 0; } - link.link_status = 1; + link.link_status = ETH_LINK_UP; link.link_duplex = ETH_LINK_FULL_DUPLEX; switch (link_speed) { diff --git a/drivers/net/mpipe/mpipe_tilegx.c b/drivers/net/mpipe/mpipe_tilegx.c index aef7600..1e04b75 100644 --- a/drivers/net/mpipe/mpipe_tilegx.c +++ b/drivers/net/mpipe/mpipe_tilegx.c @@ -397,11 +397,11 @@ mpipe_link_update(struct rte_eth_dev *dev, int wait_to_complete) if (speed == GXIO_MPIPE_LINK_1G) { new.link_speed = ETH_LINK_SPEED_1000; new.link_duplex = ETH_LINK_FULL_DUPLEX; - new.link_status = 1; + new.link_status = ETH_LINK_UP; } else if (speed == GXIO_MPIPE_LINK_10G) { new.link_speed = ETH_LINK_SPEED_10000; new.link_duplex = ETH_LINK_FULL_DUPLEX; - new.link_status = 1; + new.link_status = ETH_LINK_UP; } rc = mpipe_link_compare(&old, &new); @@ -848,9 +848,9 @@ mpipe_start(struct rte_eth_dev *dev) /* Start xmit/recv on queues. */ for (queue = 0; queue < priv->nb_tx_queues; queue++) - mpipe_tx_queue(priv, queue)->q.link_status = 1; + mpipe_tx_queue(priv, queue)->q.link_status = ETH_LINK_UP; for (queue = 0; queue < priv->nb_rx_queues; queue++) - mpipe_rx_queue(priv, queue)->q.link_status = 1; + mpipe_rx_queue(priv, queue)->q.link_status = ETH_LINK_UP; priv->running = 1; return 0; @@ -865,9 +865,9 @@ mpipe_stop(struct rte_eth_dev *dev) int rc; for (queue = 0; queue < priv->nb_tx_queues; queue++) - mpipe_tx_queue(priv, queue)->q.link_status = 0; + mpipe_tx_queue(priv, queue)->q.link_status = ETH_LINK_DOWN; for (queue = 0; queue < priv->nb_rx_queues; queue++) - mpipe_rx_queue(priv, queue)->q.link_status = 0; + mpipe_rx_queue(priv, queue)->q.link_status = ETH_LINK_DOWN; /* Make sure the link_status writes land. */ rte_wmb(); diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c index 8810704..7cb7d76 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -817,7 +817,7 @@ nfp_net_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complete) memset(&link, 0, sizeof(struct rte_eth_link)); if (nn_link_status & NFP_NET_CFG_STS_LINK) - link.link_status = 1; + link.link_status = ETH_LINK_UP; link.link_duplex = ETH_LINK_FULL_DUPLEX; /* Other cards can limit the tx and rx rate per VF */ diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 1c354ad..6adea91 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -91,7 +91,7 @@ static const char *drivername = "Null PMD"; static struct rte_eth_link pmd_link = { .link_speed = 10000, .link_duplex = ETH_LINK_FULL_DUPLEX, - .link_status = 0 + .link_status = ETH_LINK_DOWN, }; static uint16_t @@ -199,7 +199,7 @@ eth_dev_start(struct rte_eth_dev *dev) if (dev == NULL) return -EINVAL; - dev->data->dev_link.link_status = 1; + dev->data->dev_link.link_status = ETH_LINK_UP; return 0; } @@ -209,7 +209,7 @@ eth_dev_stop(struct rte_eth_dev *dev) if (dev == NULL) return; - dev->data->dev_link.link_status = 0; + dev->data->dev_link.link_status = ETH_LINK_DOWN; } static int diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c index 5202086..b90c725 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -125,7 +125,7 @@ static const char *drivername = "Pcap PMD"; static struct rte_eth_link pmd_link = { .link_speed = 10000, .link_duplex = ETH_LINK_FULL_DUPLEX, - .link_status = 0 + .link_status = ETH_LINK_DOWN, }; static int @@ -428,7 +428,7 @@ eth_dev_start(struct rte_eth_dev *dev) status_up: - dev->data->dev_link.link_status = 1; + dev->data->dev_link.link_status = ETH_LINK_UP; return 0; } @@ -479,7 +479,7 @@ eth_dev_stop(struct rte_eth_dev *dev) } status_down: - dev->data->dev_link.link_status = 0; + dev->data->dev_link.link_status = ETH_LINK_DOWN; } static int diff --git a/drivers/net/ring/rte_eth_ring.c b/drivers/net/ring/rte_eth_ring.c index ba19cd7..4335c6a 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -79,7 +79,7 @@ static const char *drivername = "Rings PMD"; static struct rte_eth_link pmd_link = { .link_speed = 10000, .link_duplex = ETH_LINK_FULL_DUPLEX, - .link_status = 0 + .link_status = ETH_LINK_DOWN, }; static uint16_t @@ -119,27 +119,27 @@ eth_dev_configure(struct rte_eth_dev *dev __rte_unused) { return 0; } static int eth_dev_start(struct rte_eth_dev *dev) { - dev->data->dev_link.link_status = 1; + dev->data->dev_link.link_status = ETH_LINK_UP; return 0; } static void eth_dev_stop(struct rte_eth_dev *dev) { - dev->data->dev_link.link_status = 0; + dev->data->dev_link.link_status = ETH_LINK_DOWN; } static int eth_dev_set_link_down(struct rte_eth_dev *dev) { - dev->data->dev_link.link_status = 0; + dev->data->dev_link.link_status = ETH_LINK_DOWN; return 0; } static int eth_dev_set_link_up(struct rte_eth_dev *dev) { - dev->data->dev_link.link_status = 1; + dev->data->dev_link.link_status = ETH_LINK_UP; return 0; } diff --git a/drivers/net/szedata2/rte_eth_szedata2.c b/drivers/net/szedata2/rte_eth_szedata2.c index 81c806e..c65067e 100644 --- a/drivers/net/szedata2/rte_eth_szedata2.c +++ b/drivers/net/szedata2/rte_eth_szedata2.c @@ -1172,7 +1172,7 @@ eth_link_update(struct rte_eth_dev *dev, link.link_duplex = ETH_LINK_FULL_DUPLEX; link.link_status = (cgmii_ibuf_is_enabled(ibuf) && - cgmii_ibuf_is_link_up(ibuf)) ? 1 : 0; + cgmii_ibuf_is_link_up(ibuf)) ? ETH_LINK_UP : ETH_LINK_DOWN; rte_atomic64_cmpset((uint64_t *)dev_link, *(uint64_t *)dev_link, *(uint64_t *)link_ptr); diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 86c96c9..3ebc221 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1410,16 +1410,16 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet offsetof(struct virtio_net_config, status), &status, sizeof(status)); if ((status & VIRTIO_NET_S_LINK_UP) == 0) { - link.link_status = 0; + link.link_status = ETH_LINK_DOWN; PMD_INIT_LOG(DEBUG, "Port %d is down", dev->data->port_id); } else { - link.link_status = 1; + link.link_status = ETH_LINK_UP; PMD_INIT_LOG(DEBUG, "Port %d is up", dev->data->port_id); } } else { - link.link_status = 1; /* Link up */ + link.link_status = ETH_LINK_UP; } virtio_dev_atomic_write_link_status(dev, &link); diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c index a5c9ba5..7fe3a53 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -760,7 +760,7 @@ vmxnet3_dev_link_update(struct rte_eth_dev *dev, __attribute__((unused)) int wai ret = VMXNET3_READ_BAR1_REG(hw, VMXNET3_REG_CMD); if (ret & 0x1) { - link.link_status = 1; + link.link_status = ETH_LINK_UP; link.link_duplex = ETH_LINK_FULL_DUPLEX; link.link_speed = ETH_LINK_SPEED_10000; } diff --git a/drivers/net/xenvirt/rte_eth_xenvirt.c b/drivers/net/xenvirt/rte_eth_xenvirt.c index 3f31806..9453a06 100644 --- a/drivers/net/xenvirt/rte_eth_xenvirt.c +++ b/drivers/net/xenvirt/rte_eth_xenvirt.c @@ -72,7 +72,7 @@ static const char *drivername = "xen virtio PMD"; static struct rte_eth_link pmd_link = { .link_speed = 10000, .link_duplex = ETH_LINK_FULL_DUPLEX, - .link_status = 0 + .link_status = ETH_LINK_DOWN, }; static void @@ -290,7 +290,7 @@ eth_dev_start(struct rte_eth_dev *dev) struct pmd_internals *pi = (struct pmd_internals *)dev->data->dev_private; int rv; - dev->data->dev_link.link_status = 1; + dev->data->dev_link.link_status = ETH_LINK_UP; while (!virtqueue_full(rxvq)) { m = rte_rxmbuf_alloc(rxvq->mpool); if (m == NULL) @@ -318,7 +318,7 @@ eth_dev_stop(struct rte_eth_dev *dev) { struct pmd_internals *pi = (struct pmd_internals *)dev->data->dev_private; - dev->data->dev_link.link_status = 0; + dev->data->dev_link.link_status = ETH_LINK_DOWN; dev_stop_notify(pi->virtio_idx); } diff --git a/examples/exception_path/main.c b/examples/exception_path/main.c index b3fe170..bec9804 100644 --- a/examples/exception_path/main.c +++ b/examples/exception_path/main.c @@ -485,7 +485,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c index 8021702..81a4918 100644 --- a/examples/ip_fragmentation/main.c +++ b/examples/ip_fragmentation/main.c @@ -631,7 +631,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c index e59a6b4..83422e8 100644 --- a/examples/ip_pipeline/init.c +++ b/examples/ip_pipeline/init.c @@ -856,7 +856,7 @@ app_check_link(struct app_params *app) link_params.link_speed / 1000, link_params.link_status ? "UP" : "DOWN"); - if (link_params.link_status == 0) + if (link_params.link_status == ETH_LINK_DOWN) all_links_up = 0; } diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c index 19ec46c..c27e735 100644 --- a/examples/ip_reassembly/main.c +++ b/examples/ip_reassembly/main.c @@ -763,7 +763,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c index d6c9a5d..393f9bd 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -945,7 +945,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c index 5dbea1a..96b4157 100644 --- a/examples/ipv4_multicast/main.c +++ b/examples/ipv4_multicast/main.c @@ -642,7 +642,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/kni/main.c b/examples/kni/main.c index 6d434ad..a5297f2 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -670,7 +670,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c index 762d22a..fef5b0c 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -1238,7 +1238,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/l2fwd-ivshmem/host/host.c b/examples/l2fwd-ivshmem/host/host.c index 6e6ed5e..4bd7c41 100644 --- a/examples/l2fwd-ivshmem/host/host.c +++ b/examples/l2fwd-ivshmem/host/host.c @@ -371,7 +371,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c index d1e9bf7..9f3a77d 100644 --- a/examples/l2fwd-jobstats/main.c +++ b/examples/l2fwd-jobstats/main.c @@ -746,7 +746,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c index 94b8677..8da89aa 100644 --- a/examples/l2fwd-keepalive/main.c +++ b/examples/l2fwd-keepalive/main.c @@ -499,7 +499,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c index e175681..1ad9488 100644 --- a/examples/l2fwd/main.c +++ b/examples/l2fwd/main.c @@ -480,7 +480,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c index 3a895b7..621872f 100644 --- a/examples/l3fwd-acl/main.c +++ b/examples/l3fwd-acl/main.c @@ -1858,7 +1858,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c index e7ebe30..5934efe 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -1509,7 +1509,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c index 8520f71..04eae16 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -746,7 +746,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c index cbc29bc..9981598 100644 --- a/examples/link_status_interrupt/main.c +++ b/examples/link_status_interrupt/main.c @@ -523,7 +523,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/load_balancer/init.c b/examples/load_balancer/init.c index a96d778..e07850b 100644 --- a/examples/load_balancer/init.c +++ b/examples/load_balancer/init.c @@ -395,7 +395,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/multi_process/client_server_mp/mp_server/init.c b/examples/multi_process/client_server_mp/mp_server/init.c index 1078ffd..ecb61c6 100644 --- a/examples/multi_process/client_server_mp/mp_server/init.c +++ b/examples/multi_process/client_server_mp/mp_server/init.c @@ -226,7 +226,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/multi_process/l2fwd_fork/main.c b/examples/multi_process/l2fwd_fork/main.c index aebf531..2dc8b82 100644 --- a/examples/multi_process/l2fwd_fork/main.c +++ b/examples/multi_process/l2fwd_fork/main.c @@ -900,7 +900,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/multi_process/symmetric_mp/main.c b/examples/multi_process/symmetric_mp/main.c index 72bad54..6bbff07 100644 --- a/examples/multi_process/symmetric_mp/main.c +++ b/examples/multi_process/symmetric_mp/main.c @@ -388,7 +388,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c index 7bcca37..aa1fdc3 100644 --- a/examples/performance-thread/l3fwd-thread/main.c +++ b/examples/performance-thread/l3fwd-thread/main.c @@ -3407,7 +3407,7 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) continue; } /* clear all_ports_up flag if any link down */ - if (link.link_status == 0) { + if (link.link_status == ETH_LINK_DOWN) { all_ports_up = 0; break; } diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index b5704e1..ec8d6b1 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -247,7 +247,7 @@ struct rte_eth_stats { struct rte_eth_link { uint16_t link_speed; /**< ETH_LINK_SPEED_[10, 100, 1000, 10000] */ uint16_t link_duplex; /**< ETH_LINK_[HALF_DUPLEX, FULL_DUPLEX] */ - uint8_t link_status : 1; /**< 1 -> link up, 0 -> link down */ + uint8_t link_status : 1; /**< ETH_LINK_[DOWN/UP] */ }__attribute__((aligned(8))); /**< aligned for atomic64 read/write */ #define ETH_LINK_SPEED_AUTONEG 0 /**< Auto-negotiate link speed. */ @@ -259,9 +259,12 @@ struct rte_eth_link { #define ETH_LINK_SPEED_20G 20000 /**< 20 gigabits/second. */ #define ETH_LINK_SPEED_40G 40000 /**< 40 gigabits/second. */ +/* Utility constants */ #define ETH_LINK_AUTONEG_DUPLEX 0 /**< Auto-negotiate duplex. */ #define ETH_LINK_HALF_DUPLEX 1 /**< Half-duplex connection. */ #define ETH_LINK_FULL_DUPLEX 2 /**< Full-duplex connection. */ +#define ETH_LINK_DOWN 0 /**< Link is down. */ +#define ETH_LINK_UP 1 /**< Link is up. */ /** * A structure used to configure the ring threshold registers of an RX/TX -- 2.7.0