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>
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;
}
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;
}
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;
}
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);
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;
}
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;
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
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;
}
close(sockfd);
}
- dev->data->dev_link.link_status = 0;
+ dev->data->dev_link.link_status = ETH_LINK_DOWN;
}
static int
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;
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;
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);
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,
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;
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;
}
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;
(*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;
}
/* 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;
* 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);
}
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);
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);
* 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;
}
/* 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);
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));
return -1;
return 0;
}
- link.link_status = 1;
+ link.link_status = ETH_LINK_UP;
link.link_duplex = ETH_LINK_FULL_DUPLEX;
switch (link_speed) {
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);
/* 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;
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();
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 */
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
if (dev == NULL)
return -EINVAL;
- dev->data->dev_link.link_status = 1;
+ dev->data->dev_link.link_status = ETH_LINK_UP;
return 0;
}
if (dev == NULL)
return;
- dev->data->dev_link.link_status = 0;
+ dev->data->dev_link.link_status = ETH_LINK_DOWN;
}
static int
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
status_up:
- dev->data->dev_link.link_status = 1;
+ dev->data->dev_link.link_status = ETH_LINK_UP;
return 0;
}
}
status_down:
- dev->data->dev_link.link_status = 0;
+ dev->data->dev_link.link_status = ETH_LINK_DOWN;
}
static int
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
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;
}
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);
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 {
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];
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;
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);
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;
}
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
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)
{
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);
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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. */
#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