From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f43.google.com (mail-wm0-f43.google.com [74.125.82.43]) by dpdk.org (Postfix) with ESMTP id 23B22532D for ; Mon, 14 Mar 2016 22:57:19 +0100 (CET) Received: by mail-wm0-f43.google.com with SMTP id p65so1792984wmp.0 for ; Mon, 14 Mar 2016 14:57:19 -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=qAayinUTu2ECYjTgWgXkx9gAV4p/mB9I5u8hln7K7WQ=; b=W8G1pk3xaZvnbc0IyZtDOe7SSteNKM5/ispIHFnLyjArE/nAH1uzRlHqXQ/ZaOPySi fQIACnw19DyKz8gP0tBTWkjfsvMkr8KH92n6LwvqobWxePvCW5tziui8IxqjUYu2QKyE 2vp2H4OZ2Omi9pVUZYVaLV4UHR/BnQBfb2LfCC+g2blOrKrGQwNsVag+LgzeT6LE2230 sVxZMsPCp6QnzwARvDqESeLP0vv3htE7ukIEi7c/qpenp4UhPc2qw+2kDRIFIeowzIys DcP1s8npjtut3RPId4XPH7LQ16BE41teUXxJWovjn2RFw+36IPFVUgdD3Y/Jb0lkf/wW D+EA== 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=qAayinUTu2ECYjTgWgXkx9gAV4p/mB9I5u8hln7K7WQ=; b=MjMKsCia71GzEc/WPB/Ov7t2WEACKGS3/XarbAdg92N0Hm1UNX2bOxezmQZz0R5ZS1 lG8mAWJiy8kXGDs3PFK8A3/AngJznVpTgvB+H+t3oKBysV+ZDatt5i2Ru9mwYm4ujZFz 42D/HkRVyVgfO77hjLO6vBjRTO9eSOIssypKh/FS7pSJ1ItyFkEZ7ARbH7FQ/Q1cO/eZ RG3ATPumxYHolfFdisqaYuAhoFiYMMnyiIayCCdsP/6OAiEZ7fubAkVEnh9ceaF5TEVf c/9duPtnU2RDmi9Qvn8oW8KuuptlP0dIHPuJxILrMrZMLLaw+qfg2NET7qeelkW5zQuw tPOg== X-Gm-Message-State: AD7BkJLGLv2DXMnA1vNl5cEaRQx0s9eGtR3kuQlLN2NE7pet/sO4XCnR4vqZzxh3ePQnkgQ3 X-Received: by 10.194.216.99 with SMTP id op3mr26989244wjc.26.1457992639004; Mon, 14 Mar 2016 14:57:19 -0700 (PDT) Received: from XPS13.localdomain (91.111.75.86.rev.sfr.net. [86.75.111.91]) by smtp.gmail.com with ESMTPSA id w133sm17918804wmd.3.2016.03.14.14.57.16 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 14 Mar 2016 14:57:18 -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: Mon, 14 Mar 2016 22:55:39 +0100 Message-Id: <1457992546-32230-2-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1457992546-32230-1-git-send-email-thomas.monjalon@6wind.com> References: <1456793151-1475-1-git-send-email-marcdevel@gmail.com> <1457992546-32230-1-git-send-email-thomas.monjalon@6wind.com> Subject: [dpdk-dev] [PATCH v10 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: Mon, 14 Mar 2016 21:57:19 -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 | 6 +++--- 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 | 6 +++--- 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, 81 insertions(+), 78 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 767f36b..24f909f 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 69df02e..f109900 100644 --- a/drivers/net/bnx2x/bnx2x_ethdev.c +++ b/drivers/net/bnx2x/bnx2x_ethdev.c @@ -286,7 +286,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 8a000c8..b0ebd35 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); @@ -427,7 +427,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) activate_slave(bonded_eth_dev, slave_port_id); } return 0; diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index b63c886..e63a7d0 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -1499,7 +1499,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; @@ -1616,7 +1616,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; } @@ -1782,7 +1782,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; @@ -1793,7 +1793,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; } @@ -1962,7 +1962,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; @@ -1990,7 +1990,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 4a843fe..58f9c7a 100644 --- a/drivers/net/e1000/em_ethdev.c +++ b/drivers/net/e1000/em_ethdev.c @@ -1073,11 +1073,11 @@ eth_em_link_update(struct rte_eth_dev *dev, int wait_to_complete) if (link_check && (link.link_status == 0)) { 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 2581995..614d8cb 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -2021,11 +2021,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 421266b..378faf2 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -1172,7 +1172,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 13c5b3d..80dc920 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -1917,7 +1917,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 8431755..62a8dff 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -2957,7 +2957,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)); @@ -2986,7 +2986,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 04f3c9f..118d3a5 100644 --- a/drivers/net/mpipe/mpipe_tilegx.c +++ b/drivers/net/mpipe/mpipe_tilegx.c @@ -391,11 +391,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); @@ -847,9 +847,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; @@ -864,9 +864,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 9c4f218..d1e004a 100644 --- a/drivers/net/nfp/nfp_net.c +++ b/drivers/net/nfp/nfp_net.c @@ -827,7 +827,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 77fc988..2e60823 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -95,7 +95,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 @@ -208,7 +208,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; } @@ -218,7 +218,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 f9230eb..2b32e8d 100644 --- a/drivers/net/pcap/rte_eth_pcap.c +++ b/drivers/net/pcap/rte_eth_pcap.c @@ -127,7 +127,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 @@ -430,7 +430,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; } @@ -481,7 +481,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 d92b088..4fcc2aa 100644 --- a/drivers/net/ring/rte_eth_ring.c +++ b/drivers/net/ring/rte_eth_ring.c @@ -73,7 +73,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 @@ -113,27 +113,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 9f86c99..38be554 100644 --- a/drivers/net/szedata2/rte_eth_szedata2.c +++ b/drivers/net/szedata2/rte_eth_szedata2.c @@ -113,7 +113,7 @@ static const char *drivername = "SZEdata2 PMD"; static struct rte_eth_link pmd_link = { .link_speed = ETH_LINK_SPEED_10G, .link_duplex = ETH_LINK_FULL_DUPLEX, - .link_status = 0 + .link_status = ETH_LINK_DOWN }; @@ -1158,7 +1158,7 @@ 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; } @@ -1188,7 +1188,7 @@ eth_dev_stop(struct rte_eth_dev *dev) dev->data->nb_rx_queues = (uint16_t)0; dev->data->nb_tx_queues = (uint16_t)0; - dev->data->dev_link.link_status = 0; + dev->data->dev_link.link_status = ETH_LINK_DOWN; } static int diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 06bddd7..76a0faf 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1392,16 +1392,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 c363bf6..06793a6 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -736,7 +736,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 d4bb7a3..f0a72fc 100644 --- a/examples/l3fwd-power/main.c +++ b/examples/l3fwd-power/main.c @@ -1508,7 +1508,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 d867976..6704a82 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