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 E16F056A2 for ; Fri, 25 Mar 2016 20:44:32 +0100 (CET) Received: by mail-wm0-f43.google.com with SMTP id l68so27186006wml.0 for ; Fri, 25 Mar 2016 12:44:32 -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=pXD9YUK2PafwBb5SNsY5EN1qtCDH+etM8sWfsXUB5f8=; b=zFGQGOeknZ37rch9eIrEsHvO6s4mKJOv9JQkCKM1pK//H8G8lyHVbZ79kBLQuxn3Li HVSYQnCRBIIImZvHj0kz8We9DVx/2RMixEHESboNPvuUmxUFhGoiKWEFVohMAYQgMGCO hSz/iVP9E+IalMJaPQ3vstHynLplcRnfQjdPHTfmX5a8BrBUm1ivuK/5IS6uUiRgLQbp Z9/qsP0+0aBLYWcPQwN5oc3ShiVkhS3hofv8DYoPE9tQYfnohxxz34LpyHxvGGxr0RUH EG7gnXL7eDsGVeo29Nj4qpO6t/L5hbUoOsu2lUhQRxjslw7VSVt8qApImLvCT14zmHfE of9Q== 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=pXD9YUK2PafwBb5SNsY5EN1qtCDH+etM8sWfsXUB5f8=; b=hGyGR14JqGSFsw6Gk6AZPcS0Wsz7UNqdDXApvsmzDJYrjT9Lad+GBLy8OjqiemtM48 aljV96YhXSElUXIrgo4lz6ja1+dttmeIjigwMWrximT5LYUViypwzjLi53SiNB5GYqrS RXGP6OIkTpe5GRSg0Pkfz3vcMUp5c8v/fyIw4YBKkQqtxO1Ga6NueNHrkoC88QSQ3OAy HsLvAvPvHcbxdmeMTuDPxDTwyoE/8cCXtAJn655tGby3nwR2Avz5Lp0uf61VuASHm/it ERCjlgrqBiyqfx3ROlBgsnHNHtL7bJeJ/79PKpoPzROKfRt7cEtUXZTe9K9KtgirnAbY xXaQ== X-Gm-Message-State: AD7BkJKInNKnDEQ51OSiFlhg3LBbS4M3nNtCLTXjHb4qg75/ieM+bTqe8XPGvvCtMlHxiCFJ X-Received: by 10.194.205.103 with SMTP id lf7mr16417172wjc.147.1458935072752; Fri, 25 Mar 2016 12:44:32 -0700 (PDT) Received: from XPS13.localdomain (91.111.75.86.rev.sfr.net. [86.75.111.91]) by smtp.gmail.com with ESMTPSA id u4sm13240660wjz.4.2016.03.25.12.44.29 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Mar 2016 12:44:32 -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: Fri, 25 Mar 2016 20:42:23 +0100 Message-Id: <1458934950-23333-2-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1458934950-23333-1-git-send-email-thomas.monjalon@6wind.com> References: <1458238145-7496-1-git-send-email-thomas.monjalon@6wind.com> <1458934950-23333-1-git-send-email-thomas.monjalon@6wind.com> Subject: [dpdk-dev] [PATCH v12 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: Fri, 25 Mar 2016 19:44:33 -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/vhost/rte_eth_vhost.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 ++++- 46 files changed, 83 insertions(+), 80 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 8605e62..1398c6c 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 7e5be08..a3c6c01 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 d473ac2..e9247b5 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); @@ -420,7 +420,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 fb26d35..684f285 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -1506,7 +1506,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; @@ -1623,7 +1623,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; } @@ -1789,7 +1789,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; @@ -1800,7 +1800,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; } @@ -1969,7 +1969,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; @@ -1997,7 +1997,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 1f0a7f4..dc9ed38 100644 --- a/drivers/net/e1000/em_ethdev.c +++ b/drivers/net/e1000/em_ethdev.c @@ -1101,14 +1101,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 bd0ae26..045fc63 100644 --- a/drivers/net/e1000/igb_ethdev.c +++ b/drivers/net/e1000/igb_ethdev.c @@ -2059,11 +2059,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 b510487..53aa1bb 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 a13d9cc..91df13b 100644 --- a/drivers/net/i40e/i40e_ethdev_vf.c +++ b/drivers/net/i40e/i40e_ethdev_vf.c @@ -2127,7 +2127,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 5812d10..129f36a 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -3059,7 +3059,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)); @@ -3088,7 +3088,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 7180e5a..d93ab7e 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 92ae48a..80dda85 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 1d6a600..47aa7e3 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/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index ec19c22..4cc6bec 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -110,7 +110,7 @@ static pthread_t session_th; static struct rte_eth_link pmd_link = { .link_speed = 10000, .link_duplex = ETH_LINK_FULL_DUPLEX, - .link_status = 0 + .link_status = ETH_LINK_DOWN }; struct rte_vhost_vring_state { @@ -265,7 +265,7 @@ new_device(struct virtio_net *dev) dev->flags |= VIRTIO_DEV_RUNNING; dev->priv = eth_dev; - eth_dev->data->dev_link.link_status = 1; + eth_dev->data->dev_link.link_status = ETH_LINK_UP; for (i = 0; i < eth_dev->data->nb_rx_queues; i++) { vq = eth_dev->data->rx_queues[i]; @@ -323,7 +323,7 @@ destroy_device(volatile struct virtio_net *dev) rte_pause(); } - eth_dev->data->dev_link.link_status = 0; + eth_dev->data->dev_link.link_status = ETH_LINK_DOWN; dev->priv = NULL; dev->flags &= ~VIRTIO_DEV_RUNNING; 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 f2b6b92..3f26217 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c @@ -777,7 +777,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 5fd4ff1..1c3aaa0 100644 --- a/examples/l2fwd-crypto/main.c +++ b/examples/l2fwd-crypto/main.c @@ -1277,7 +1277,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 e10dab9..5c627e5 100644 --- a/examples/l3fwd/main.c +++ b/examples/l3fwd/main.c @@ -769,7 +769,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 61c023e..15c0a4d 100644 --- a/examples/performance-thread/l3fwd-thread/main.c +++ b/examples/performance-thread/l3fwd-thread/main.c @@ -3408,7 +3408,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 e7de34a..c5a215a 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