ethdev: use constants for link state
authorThomas Monjalon <thomas.monjalon@6wind.com>
Thu, 31 Mar 2016 22:12:24 +0000 (00:12 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Fri, 1 Apr 2016 19:38:34 +0000 (21:38 +0200)
Define and use ETH_LINK_UP and ETH_LINK_DOWN where appropriate.

Signed-off-by: Marc Sune <marcdevel@gmail.com>
Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
46 files changed:
app/test-pipeline/init.c
app/test-pmd/testpmd.c
app/test/test_pmd_perf.c
app/test/virtual_pmd.c
drivers/net/af_packet/rte_eth_af_packet.c
drivers/net/bnx2x/bnx2x_ethdev.c
drivers/net/bnx2x/elink.c
drivers/net/bonding/rte_eth_bond_api.c
drivers/net/bonding/rte_eth_bond_pmd.c
drivers/net/e1000/em_ethdev.c
drivers/net/e1000/igb_ethdev.c
drivers/net/fm10k/fm10k_ethdev.c
drivers/net/i40e/i40e_ethdev_vf.c
drivers/net/ixgbe/ixgbe_ethdev.c
drivers/net/mpipe/mpipe_tilegx.c
drivers/net/nfp/nfp_net.c
drivers/net/null/rte_eth_null.c
drivers/net/pcap/rte_eth_pcap.c
drivers/net/ring/rte_eth_ring.c
drivers/net/szedata2/rte_eth_szedata2.c
drivers/net/vhost/rte_eth_vhost.c
drivers/net/virtio/virtio_ethdev.c
drivers/net/vmxnet3/vmxnet3_ethdev.c
drivers/net/xenvirt/rte_eth_xenvirt.c
examples/exception_path/main.c
examples/ip_fragmentation/main.c
examples/ip_pipeline/init.c
examples/ip_reassembly/main.c
examples/ipsec-secgw/ipsec-secgw.c
examples/ipv4_multicast/main.c
examples/kni/main.c
examples/l2fwd-crypto/main.c
examples/l2fwd-ivshmem/host/host.c
examples/l2fwd-jobstats/main.c
examples/l2fwd-keepalive/main.c
examples/l2fwd/main.c
examples/l3fwd-acl/main.c
examples/l3fwd-power/main.c
examples/l3fwd/main.c
examples/link_status_interrupt/main.c
examples/load_balancer/init.c
examples/multi_process/client_server_mp/mp_server/init.c
examples/multi_process/l2fwd_fork/main.c
examples/multi_process/symmetric_mp/main.c
examples/performance-thread/l3fwd-thread/main.c
lib/librte_ether/rte_ethdev.h

index db2196b..aef082f 100644 (file)
@@ -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;
        }
 
index 8605e62..1398c6c 100644 (file)
@@ -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;
                        }
index 48e16c9..59803f7 100644 (file)
@@ -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;
                        }
index a538c8a..b1d40d7 100644 (file)
@@ -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;
 
index 5544528..dee7b59 100644 (file)
@@ -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
index 7e5be08..a3c6c01 100644 (file)
@@ -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;
index da2366e..b9149b8 100644 (file)
@@ -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;
index d473ac2..e9247b5 100644 (file)
@@ -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,
index f0960c6..54788cf 100644 (file)
@@ -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;
@@ -1630,7 +1630,7 @@ bond_ethdev_stop(struct rte_eth_dev *eth_dev)
        for (i = 0; i < internals->slave_count; i++)
                internals->slaves[i].last_link_status = 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;
 }
 
@@ -1796,7 +1796,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;
@@ -1807,7 +1807,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;
                        }
@@ -1976,7 +1976,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;
 
@@ -2004,7 +2004,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);
                }
index 9b5e1af..9c50674 100644 (file)
@@ -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);
 
index bd0ae26..045fc63 100644 (file)
@@ -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);
 
index b03c802..b76e9e5 100644 (file)
@@ -1251,7 +1251,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;
 }
index a13d9cc..91df13b 100644 (file)
@@ -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);
 
index 78524b2..8bcd0d8 100644 (file)
@@ -3064,7 +3064,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));
@@ -3093,7 +3093,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) {
index 7180e5a..d93ab7e 100644 (file)
@@ -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();
index f12288c..0044897 100644 (file)
@@ -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 */
index 1c354ad..6adea91 100644 (file)
@@ -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
index 5202086..b90c725 100644 (file)
@@ -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
index ba19cd7..4335c6a 100644 (file)
@@ -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;
 }
 
index 1d6a600..47aa7e3 100644 (file)
@@ -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);
index ec19c22..4cc6bec 100644 (file)
@@ -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;
index 86c96c9..3ebc221 100644 (file)
@@ -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);
 
index b0588ef..b492837 100644 (file)
@@ -776,7 +776,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;
        }
index 3f31806..9453a06 100644 (file)
@@ -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);
 }
 
index b3fe170..bec9804 100644 (file)
@@ -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;
                        }
index 8021702..81a4918 100644 (file)
@@ -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;
                        }
index e59a6b4..83422e8 100644 (file)
@@ -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;
        }
 
index 19ec46c..c27e735 100644 (file)
@@ -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;
                        }
index 1d6c81b..00ab2d8 100644 (file)
@@ -947,7 +947,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;
                        }
index 5dbea1a..96b4157 100644 (file)
@@ -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;
                        }
index 6d434ad..a5297f2 100644 (file)
@@ -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;
                        }
index 09a07d3..35171d1 100644 (file)
@@ -1440,7 +1440,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;
                        }
index 6e6ed5e..4bd7c41 100644 (file)
@@ -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;
                        }
index d1e9bf7..9f3a77d 100644 (file)
@@ -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;
                        }
index 94b8677..8da89aa 100644 (file)
@@ -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;
                        }
index e175681..1ad9488 100644 (file)
@@ -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;
                        }
index 3a895b7..621872f 100644 (file)
@@ -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;
                        }
index e7ebe30..5934efe 100644 (file)
@@ -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;
                        }
index 92fda3b..bf6d885 100644 (file)
@@ -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;
                        }
index cbc29bc..9981598 100644 (file)
@@ -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;
                        }
index a96d778..e07850b 100644 (file)
@@ -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;
                        }
index 1078ffd..ecb61c6 100644 (file)
@@ -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;
                        }
index aebf531..2dc8b82 100644 (file)
@@ -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;
                        }
index 72bad54..6bbff07 100644 (file)
@@ -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;
                        }
index 61c023e..15c0a4d 100644 (file)
@@ -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;
                        }
index e7de34a..c5a215a 100644 (file)
@@ -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