Page MenuHomeFreeBSD

D12861.id34524.diff
No OneTemporary

D12861.id34524.diff

Index: sys/dev/ena/ena.c
===================================================================
--- sys/dev/ena/ena.c
+++ sys/dev/ena/ena.c
@@ -227,7 +227,7 @@
maxsize = ((size - 1) / PAGE_SIZE + 1) * PAGE_SIZE;
dma_space_addr = ENA_DMA_BIT_MASK(adapter->dma_width);
- if (dma_space_addr == 0)
+ if (unlikely(dma_space_addr == 0))
dma_space_addr = BUS_SPACE_MAXADDR;
error = bus_dma_tag_create(bus_get_dma_tag(dmadev), /* parent */
@@ -242,7 +242,7 @@
NULL, /* lockfunc */
NULL, /* lockarg */
&dma->tag);
- if (error != 0) {
+ if (unlikely(error != 0)) {
device_printf(dmadev, "%s: bus_dma_tag_create failed: %d\n",
__func__, error);
goto fail_tag;
@@ -250,7 +250,7 @@
error = bus_dmamem_alloc(dma->tag, (void**) &dma->vaddr,
BUS_DMA_COHERENT | BUS_DMA_ZERO, &dma->map);
- if (error != 0) {
+ if (unlikely(error != 0)) {
device_printf(dmadev, "%s: bus_dmamem_alloc(%ju) failed: %d\n",
__func__, (uintmax_t)size, error);
goto fail_map_create;
@@ -259,7 +259,7 @@
dma->paddr = 0;
error = bus_dmamap_load(dma->tag, dma->map, dma->vaddr,
size, ena_dmamap_callback, &dma->paddr, mapflags);
- if ((error != 0) || (dma->paddr == 0)) {
+ if (unlikely((error != 0) || (dma->paddr == 0))) {
device_printf(dmadev, "%s: bus_dmamap_load failed: %d\n",
__func__, error);
goto fail_map_load;
@@ -287,7 +287,7 @@
adapter->memory = NULL;
adapter->registers = bus_alloc_resource_any(pdev, SYS_RES_MEMORY,
&rid, RF_ACTIVE);
- if (adapter->registers == NULL) {
+ if (unlikely(adapter->registers == NULL)) {
device_printf(pdev, "Unable to allocate bus resource: "
"registers\n");
return (ENXIO);
@@ -350,7 +350,7 @@
int rc, old_mtu, max_frame;
rc = ena_com_get_dev_attr_feat(adapter->ena_dev, &get_feat_ctx);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev,
"Cannot get attribute for ena device\n");
return (ENXIO);
@@ -363,9 +363,9 @@
if_setmtu(ifp, new_mtu);
max_frame = ETHER_MAX_FRAME(ifp, ETHERTYPE_VLAN, 1);
- if ((new_mtu < ENA_MIN_FRAME_LEN) ||
+ if (unlikely((new_mtu < ENA_MIN_FRAME_LEN) ||
(new_mtu > get_feat_ctx.dev_attr.max_mtu) ||
- (max_frame > ENA_MAX_FRAME_LEN)) {
+ (max_frame > ENA_MAX_FRAME_LEN))) {
device_printf(adapter->pdev, "Invalid MTU setting. "
"new_mtu: %d\n", new_mtu);
goto error;
@@ -447,7 +447,7 @@
/* Allocate a buf ring */
txr->br = buf_ring_alloc(ena_buf_ring_size, M_DEVBUF,
M_WAITOK, &txr->ring_mtx);
- if (txr->br == NULL) {
+ if (unlikely(txr->br == NULL)) {
device_printf(adapter->pdev,
"Error while setting up bufring\n");
rc = ENOMEM;
@@ -546,7 +546,7 @@
NULL, /* lockfuncarg */
&adapter->tx_buf_tag);
- if (ret != 0)
+ if (unlikely(ret != 0))
device_printf(adapter->pdev, "Unable to create Tx DMA tag\n");
return (ret);
@@ -559,7 +559,7 @@
ret = bus_dma_tag_destroy(adapter->tx_buf_tag);
- if (ret == 0)
+ if (likely(ret == 0))
adapter->tx_buf_tag = NULL;
return (ret);
@@ -584,7 +584,7 @@
NULL, /* lockarg */
&adapter->rx_buf_tag);
- if (ret != 0)
+ if (unlikely(ret != 0))
device_printf(adapter->pdev, "Unable to create Rx DMA tag\n");
return (ret);
@@ -597,7 +597,7 @@
ret = bus_dma_tag_destroy(adapter->rx_buf_tag);
- if (ret == 0)
+ if (likely(ret == 0))
adapter->rx_buf_tag = NULL;
return (ret);
@@ -623,12 +623,12 @@
size = sizeof(struct ena_tx_buffer) * tx_ring->ring_size;
tx_ring->tx_buffer_info = malloc(size, M_DEVBUF, M_NOWAIT | M_ZERO);
- if (tx_ring->tx_buffer_info == NULL)
+ if (unlikely(tx_ring->tx_buffer_info == NULL))
return (ENOMEM);
size = sizeof(uint16_t) * tx_ring->ring_size;
tx_ring->free_tx_ids = malloc(size, M_DEVBUF, M_NOWAIT | M_ZERO);
- if (tx_ring->free_tx_ids == NULL)
+ if (unlikely(tx_ring->free_tx_ids == NULL))
goto err_buf_info_free;
/* Req id stack for TX OOO completions */
@@ -651,7 +651,7 @@
for (i = 0; i < tx_ring->ring_size; i++) {
err = bus_dmamap_create(adapter->tx_buf_tag, 0,
&tx_ring->tx_buffer_info[i].map);
- if (err != 0) {
+ if (unlikely(err != 0)) {
device_printf(adapter->pdev,
"Unable to create Tx DMA map for buffer %d\n", i);
goto err_buf_info_unmap;
@@ -662,7 +662,7 @@
TASK_INIT(&tx_ring->enqueue_task, 0, ena_deferred_mq_start, tx_ring);
tx_ring->enqueue_tq = taskqueue_create_fast("ena_tx_enque", M_NOWAIT,
taskqueue_thread_enqueue, &tx_ring->enqueue_tq);
- if (tx_ring->enqueue_tq == NULL) {
+ if (unlikely(tx_ring->enqueue_tq == NULL)) {
device_printf(adapter->pdev,
"Unable to create taskqueue for enqueue task\n");
i = tx_ring->ring_size;
@@ -871,7 +871,7 @@
rx_ring->cmpl_tq = taskqueue_create_fast("ena RX completion", M_NOWAIT,
taskqueue_thread_enqueue, &rx_ring->cmpl_tq);
- if (rx_ring->cmpl_tq == NULL) {
+ if (unlikely(rx_ring->cmpl_tq == NULL)) {
device_printf(adapter->pdev,
"Unable to create taskqueue for cmpl task\n");
i = rx_ring->ring_size;
@@ -1001,13 +1001,13 @@
int nsegs, error;
/* if previous allocated frag is not used */
- if (rx_info->mbuf != NULL)
+ if (unlikely(rx_info->mbuf != NULL))
return (0);
/* Get mbuf using UMA allocator */
rx_info->mbuf = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUM16BYTES);
- if (rx_info->mbuf == NULL) {
+ if (unlikely(rx_info->mbuf == NULL)) {
counter_u64_add(rx_ring->rx_stats.mbuf_alloc_fail, 1);
return (ENOMEM);
}
@@ -1020,7 +1020,7 @@
adapter->rx_buf_tag,rx_info->mbuf, rx_info->mbuf->m_len);
error = bus_dmamap_load_mbuf_sg(adapter->rx_buf_tag, rx_info->map,
rx_info->mbuf, segs, &nsegs, BUS_DMA_NOWAIT);
- if ((error != 0) || (nsegs != 1)) {
+ if (unlikely((error != 0) || (nsegs != 1))) {
device_printf(adapter->pdev, "failed to map mbuf, error: %d, "
"nsegs: %d\n", error, nsegs);
counter_u64_add(rx_ring->rx_stats.dma_mapping_err, 1);
@@ -1092,7 +1092,7 @@
rx_info = &rx_ring->rx_buffer_info[req_id];
rc = ena_alloc_rx_mbuf(adapter, rx_ring, rx_info);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev,
"failed to alloc buffer for rx queue\n");
break;
@@ -1109,14 +1109,14 @@
rx_ring->ring_size);
}
- if (i < num) {
+ if (unlikely(i < num)) {
counter_u64_add(rx_ring->rx_stats.refil_partial, 1);
device_printf(adapter->pdev,
"refilled rx queue %d with %d pages only\n",
rx_ring->qid, i);
}
- if (i != 0) {
+ if (likely(i != 0)) {
wmb();
ena_com_write_sq_doorbell(rx_ring->ena_com_io_sq);
}
@@ -1300,7 +1300,7 @@
ctx.msix_vector = msix_vector;
ctx.qid = ena_qid;
rc = ena_com_create_io_queue(ena_dev, &ctx);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev,
"Failed to create io RX queue[%d] rc: %d\n", i, rc);
goto err_rx;
@@ -1310,7 +1310,7 @@
rc = ena_com_get_io_handlers(ena_dev, ena_qid,
&ring->ena_com_io_sq,
&ring->ena_com_io_cq);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev,
"Failed to get RX queue handlers. RX queue num"
" %d rc: %d\n", i, rc);
@@ -1367,11 +1367,11 @@
struct mbuf *mbuf;
rc = ena_com_tx_comp_req_id_get(io_cq, &req_id);
- if (rc != 0)
+ if (unlikely(rc != 0))
break;
rc = validate_tx_req_id(tx_ring, req_id);
- if (rc != 0)
+ if (unlikely(rc != 0))
break;
tx_info = &tx_ring->tx_buffer_info[req_id];
@@ -1381,7 +1381,7 @@
tx_info->mbuf = NULL;
bintime_clear(&tx_info->timestamp);
- if (tx_info->num_of_bufs != 0) {
+ if (likely(tx_info->num_of_bufs != 0)) {
/* Map is no longer required */
bus_dmamap_unload(adapter->tx_buf_tag, tx_info->map);
}
@@ -1394,7 +1394,7 @@
next_to_clean = ENA_TX_RING_IDX_NEXT(next_to_clean,
tx_ring->ring_size);
- if (--commit == 0) {
+ if (unlikely(--commit == 0)) {
commit = TX_COMMIT;
/* update ring state every TX_COMMIT descriptor */
tx_ring->next_to_clean = next_to_clean;
@@ -1404,12 +1404,12 @@
ena_com_update_dev_comp_head(io_cq);
total_done = 0;
}
- } while (--budget);
+ } while (likely(--budget));
work_done = TX_BUDGET - budget;
/* If there is still something to commit update ring state */
- if (commit != TX_COMMIT) {
+ if (likely(commit != TX_COMMIT)) {
tx_ring->next_to_clean = next_to_clean;
ena_com_comp_ack(&adapter->ena_dev->io_sq_queues[ena_qid],
total_done);
@@ -1427,7 +1427,7 @@
{
struct ena_adapter *adapter = rx_ring->adapter;
- if (adapter->rss_support == true) {
+ if (likely(adapter->rss_support == true)) {
mbuf->m_pkthdr.flowid = ena_rx_ctx->hash;
if ((ena_rx_ctx->frag == true) &&
@@ -1551,7 +1551,7 @@
goto err_mbuf_null;
}
- if (m_append(mbuf, len, rx_info->mbuf->m_data) == 0) {
+ if (unlikely(m_append(mbuf, len, rx_info->mbuf->m_data) == 0)) {
counter_u64_add(rx_ring->rx_stats.mbuf_alloc_fail, 1);
ena_trace(ENA_WARNING, "Failed to append Rx mbuf %p",
mbuf);
@@ -1584,8 +1584,8 @@
{
/* if IP and error */
- if ((ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV4) &&
- (ena_rx_ctx->l3_csum_err == true)) {
+ if (unlikely((ena_rx_ctx->l3_proto == ENA_ETH_IO_L3_PROTO_IPV4) &&
+ (ena_rx_ctx->l3_csum_err == true))) {
/* ipv4 checksum error */
mbuf->m_pkthdr.csum_flags = 0;
counter_u64_add(rx_ring->rx_stats.bad_csum, 1);
@@ -1617,7 +1617,7 @@
* If deferred task was executed, perform cleanup of all awaiting
* descs (or until given budget is depleted to avoid infinite loop).
*/
- while (budget--) {
+ while (likely(budget--)) {
if (ena_rx_cleanup(rx_ring) == 0)
break;
}
@@ -1782,7 +1782,7 @@
int qid, ena_qid;
int txc, rxc, i;
- if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
+ if (unlikely((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0))
return;
ena_trace(ENA_DBG, "MSI-X TX/RX routine");
@@ -1799,7 +1799,7 @@
* being executed and rx ring is being cleaned up in
* another thread.
*/
- if (ENA_RING_MTX_TRYLOCK(rx_ring) != 0) {
+ if (likely(ENA_RING_MTX_TRYLOCK(rx_ring) != 0)) {
rxc = ena_rx_cleanup(rx_ring);
ENA_RING_MTX_UNLOCK(rx_ring);
} else {
@@ -1811,7 +1811,7 @@
txc = ena_tx_cleanup(tx_ring);
ENA_RING_MTX_UNLOCK(tx_ring);
- if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0)
+ if (unlikely((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0))
return;
if ((txc != TX_BUDGET) && (rxc != RX_BUDGET))
@@ -1837,7 +1837,7 @@
adapter->msix_entries = malloc(msix_vecs * sizeof(struct msix_entry),
M_DEVBUF, M_WAITOK | M_ZERO);
- if (adapter->msix_entries == NULL) {
+ if (unlikely(adapter->msix_entries == NULL)) {
device_printf(dev,
"Failed to allocate msix_entries, vectors %d\n", msix_vecs);
return (ENOMEM);
@@ -1852,7 +1852,7 @@
}
rc = pci_alloc_msix(dev, &msix_vecs);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(dev,
"Failed to enable MSIX, vectors %d rc %d\n", msix_vecs, rc);
@@ -1915,7 +1915,7 @@
* We still want to bind rings to the corresponding cpu
* using something similar to the RSS round-robin technique.
*/
- if (last_bind_cpu < 0)
+ if (unlikely(last_bind_cpu < 0))
last_bind_cpu = CPU_FIRST();
adapter->que[i].cpu = adapter->irq_tbl[irq_idx].cpu =
last_bind_cpu;
@@ -1937,7 +1937,7 @@
irq->res = bus_alloc_resource_any(adapter->pdev, SYS_RES_IRQ,
&irq->vector, flags);
- if (irq->res == NULL) {
+ if (unlikely(irq->res == NULL)) {
device_printf(adapter->pdev, "could not allocate "
"irq vector: %d\n", irq->vector);
return (ENXIO);
@@ -1945,7 +1945,7 @@
rc = bus_activate_resource(adapter->pdev, SYS_RES_IRQ,
irq->vector, irq->res);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev, "could not activate "
"irq vector: %d\n", irq->vector);
goto err_res_free;
@@ -1954,7 +1954,7 @@
rc = bus_setup_intr(adapter->pdev, irq->res,
INTR_TYPE_NET | INTR_MPSAFE, NULL, ena_intr_msix_mgmnt,
irq->data, &irq->cookie);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev, "failed to register "
"interrupt handler for irq %ju: %d\n",
rman_get_start(irq->res), rc);
@@ -1969,7 +1969,7 @@
irq->vector);
rcc = bus_release_resource(adapter->pdev, SYS_RES_IRQ,
irq->vector, irq->res);
- if (rcc != 0)
+ if (unlikely(rcc != 0))
device_printf(adapter->pdev, "dev has no parent while "
"releasing res for irq: %d\n", irq->vector);
irq->res = NULL;
@@ -1984,7 +1984,7 @@
unsigned long flags = 0;
int rc = 0, i, rcc;
- if (adapter->msix_enabled == 0) {
+ if (unlikely(adapter->msix_enabled == 0)) {
device_printf(adapter->pdev, "failed to request irq\n");
return (EINVAL);
} else {
@@ -1994,12 +1994,12 @@
for (i = ENA_IO_IRQ_FIRST_IDX; i < adapter->msix_vecs; i++) {
irq = &adapter->irq_tbl[i];
- if (irq->requested == true)
+ if (unlikely(irq->requested == true))
continue;
irq->res = bus_alloc_resource_any(adapter->pdev, SYS_RES_IRQ,
&irq->vector, flags);
- if (irq->res == NULL) {
+ if (unlikely(irq->res == NULL)) {
device_printf(adapter->pdev, "could not allocate "
"irq vector: %d\n", irq->vector);
goto err;
@@ -2008,7 +2008,7 @@
rc = bus_setup_intr(adapter->pdev, irq->res,
INTR_TYPE_NET | INTR_MPSAFE, NULL,
irq->handler, irq->data, &irq->cookie);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev, "failed to register "
"interrupt handler for irq %ju: %d\n",
rman_get_start(irq->res), rc);
@@ -2037,7 +2037,7 @@
free both intr and resources */
if (irq->requested == true)
rcc = bus_teardown_intr(adapter->pdev, irq->res, irq->cookie);
- if (rcc != 0)
+ if (unlikely(rcc != 0))
device_printf(adapter->pdev, "could not release"
" irq: %d, error: %d\n", irq->vector, rcc);
@@ -2050,7 +2050,7 @@
rcc = bus_release_resource(adapter->pdev, SYS_RES_IRQ,
irq->vector, irq->res);
}
- if (rcc != 0)
+ if (unlikely(rcc != 0))
device_printf(adapter->pdev, "dev has no parent while "
"releasing res for irq: %d\n", irq->vector);
irq->requested = false;
@@ -2071,7 +2071,7 @@
ena_trace(ENA_INFO | ENA_ADMQ, "tear down irq: %d\n",
irq->vector);
rc = bus_teardown_intr(adapter->pdev, irq->res, irq->cookie);
- if (rc != 0)
+ if (unlikely(rc != 0))
device_printf(adapter->pdev, "failed to tear "
"down irq: %d\n", irq->vector);
irq->requested = 0;
@@ -2083,7 +2083,7 @@
rc = bus_release_resource(adapter->pdev, SYS_RES_IRQ,
irq->vector, irq->res);
irq->res = NULL;
- if (rc != 0)
+ if (unlikely(rc != 0))
device_printf(adapter->pdev, "dev has no parent while "
"releasing res for irq: %d\n", irq->vector);
}
@@ -2102,7 +2102,7 @@
irq->vector);
rc = bus_teardown_intr(adapter->pdev, irq->res,
irq->cookie);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev, "failed to tear "
"down irq: %d\n", irq->vector);
}
@@ -2115,7 +2115,7 @@
rc = bus_release_resource(adapter->pdev, SYS_RES_IRQ,
irq->vector, irq->res);
irq->res = NULL;
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev, "dev has no parent"
" while releasing res for irq: %d\n",
irq->vector);
@@ -2191,14 +2191,14 @@
{
int rc;
- if (adapter->rss_support == true) {
+ if (likely(adapter->rss_support == true)) {
rc = ena_rss_configure(adapter);
if (rc != 0)
return (rc);
}
rc = ena_change_mtu(adapter->ifp, adapter->ifp->if_mtu);
- if (rc != 0)
+ if (unlikely(rc != 0))
return (rc);
ena_refill_all_rx_bufs(adapter);
@@ -2213,12 +2213,12 @@
{
int rc = 0;
- if (device_is_attached(adapter->pdev) == 0) {
+ if (unlikely(device_is_attached(adapter->pdev) == 0)) {
device_printf(adapter->pdev, "device is not attached!\n");
return (ENXIO);
}
- if (adapter->running == false) {
+ if (unlikely(adapter->running == false)) {
device_printf(adapter->pdev, "device is not running!\n");
return (ENXIO);
}
@@ -2229,38 +2229,38 @@
/* setup interrupts for IO queues */
ena_setup_io_intr(adapter);
rc = ena_request_io_irq(adapter);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
ena_trace(ENA_ALERT, "err_req_irq");
goto err_req_irq;
}
/* allocate transmit descriptors */
rc = ena_setup_all_tx_resources(adapter);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
ena_trace(ENA_ALERT, "err_setup_tx");
goto err_setup_tx;
}
/* allocate receive descriptors */
rc = ena_setup_all_rx_resources(adapter);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
ena_trace(ENA_ALERT, "err_setup_rx");
goto err_setup_rx;
}
/* create IO queues for Rx & Tx */
rc = ena_create_io_queues(adapter);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
ena_trace(ENA_ALERT,
"create IO queues failed");
goto err_io_que;
}
- if (adapter->link_status == true)
+ if (unlikely(adapter->link_status == true))
if_link_state_change(adapter->ifp, LINK_STATE_UP);
rc = ena_up_complete(adapter);
- if (rc != 0)
+ if (unlikely(rc != 0))
goto err_up_complete;
counter_u64_add(adapter->dev_stats.interface_up, 1);
@@ -2530,7 +2530,7 @@
ena_trace(ENA_DBG, "enter");
ifp = adapter->ifp = if_gethandle(IFT_ETHER);
- if (ifp == NULL) {
+ if (unlikely(ifp == NULL)) {
device_printf(pdev, "can not allocate ifnet structure\n");
return (ENXIO);
}
@@ -2599,7 +2599,7 @@
if (adapter->trigger_reset == true) {
rc = ena_com_dev_reset(adapter->ena_dev,
adapter->reset_reason);
- if (rc != 0)
+ if (unlikely(rc != 0))
device_printf(adapter->pdev,
"Device reset failed\n");
}
@@ -2723,7 +2723,7 @@
collapsed_mbuf = m_collapse(*mbuf, M_NOWAIT,
adapter->max_tx_sgl_size - 1);
- if (collapsed_mbuf == NULL) {
+ if (unlikely(collapsed_mbuf == NULL)) {
counter_u64_add(tx_ring->tx_stats.collapse_err, 1);
return (ENOMEM);
}
@@ -2759,7 +2759,7 @@
io_sq = &adapter->ena_dev->io_sq_queues[ena_qid];
rc = ena_check_and_collapse_mbuf(tx_ring, mbuf);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
ena_trace(ENA_WARNING,
"Failed to collapse mbuf! err: %d", rc);
return (rc);
@@ -2784,7 +2784,7 @@
rc = bus_dmamap_load_mbuf_sg(adapter->tx_buf_tag, tx_info->map,
*mbuf, segs, &nsegs, BUS_DMA_NOWAIT);
- if ((rc != 0) || (nsegs == 0)) {
+ if (unlikely((rc != 0) || (nsegs == 0))) {
ena_trace(ENA_WARNING,
"dmamap load failed! err: %d nsegs: %d", rc, nsegs);
counter_u64_add(tx_ring->tx_stats.dma_mapping_err, 1);
@@ -2813,7 +2813,7 @@
ena_tx_csum(&ena_tx_ctx, *mbuf);
/* Prepare the packet's descriptors and send them to device */
rc = ena_com_prepare_tx(io_sq, &ena_tx_ctx, &nb_hw_desc);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
ena_trace(ENA_WARNING, "failed to prepare tx bufs\n");
counter_enter();
counter_u64_add_protected(tx_ring->tx_stats.queue_stop, 1);
@@ -2861,10 +2861,10 @@
int acum_pkts = 0;
int ret = 0;
- if ((if_getdrvflags(adapter->ifp) & IFF_DRV_RUNNING) == 0)
+ if (unlikely((if_getdrvflags(adapter->ifp) & IFF_DRV_RUNNING) == 0))
return;
- if (adapter->link_status == false)
+ if (unlikely(adapter->link_status == false))
return;
ena_qid = ENA_IO_TXQ_IDX(tx_ring->que->id);
@@ -2875,11 +2875,11 @@
" header csum flags %#jx",
mbuf, mbuf->m_flags, mbuf->m_pkthdr.csum_flags);
- if (ena_com_sq_have_enough_space(io_sq,
- ENA_TX_CLEANUP_THRESHOLD) == false)
+ if (unlikely(ena_com_sq_have_enough_space(io_sq,
+ ENA_TX_CLEANUP_THRESHOLD) == false))
ena_tx_cleanup(tx_ring);
- if ((ret = ena_xmit_mbuf(tx_ring, &mbuf)) != 0) {
+ if (unlikely((ret = ena_xmit_mbuf(tx_ring, &mbuf)) != 0)) {
if (ret == ENA_COM_NO_MEM) {
drbr_putback(adapter->ifp, tx_ring->br, mbuf);
} else if (ret == ENA_COM_NO_SPACE) {
@@ -2894,14 +2894,15 @@
drbr_advance(adapter->ifp, tx_ring->br);
- if ((if_getdrvflags(adapter->ifp) & IFF_DRV_RUNNING) == 0)
+ if (unlikely((if_getdrvflags(adapter->ifp) &
+ IFF_DRV_RUNNING) == 0))
return;
acum_pkts++;
BPF_MTAP(adapter->ifp, mbuf);
- if (acum_pkts == DB_THRESHOLD) {
+ if (unlikely(acum_pkts == DB_THRESHOLD)) {
acum_pkts = 0;
wmb();
/* Trigger the dma engine */
@@ -2911,7 +2912,7 @@
}
- if (acum_pkts != 0) {
+ if (likely(acum_pkts != 0)) {
wmb();
/* Trigger the dma engine */
ena_com_write_sq_doorbell(io_sq);
@@ -2945,7 +2946,7 @@
int ret, is_drbr_empty;
uint32_t i;
- if ((if_getdrvflags(adapter->ifp) & IFF_DRV_RUNNING) == 0)
+ if (unlikely((if_getdrvflags(adapter->ifp) & IFF_DRV_RUNNING) == 0))
return (ENODEV);
/* Which queue to use */
@@ -2973,7 +2974,7 @@
/* Check if drbr is empty before putting packet */
is_drbr_empty = drbr_empty(ifp, tx_ring->br);
ret = drbr_enqueue(ifp, tx_ring->br, m);
- if (ret != 0) {
+ if (unlikely(ret != 0)) {
taskqueue_enqueue(tx_ring->enqueue_tq, &tx_ring->enqueue_task);
return (ret);
}
@@ -3123,7 +3124,7 @@
int rc;
dc = devclass_find("ena");
- if (dc == NULL) {
+ if (unlikely(dc == NULL)) {
ena_trace(ENA_DBG, "No devclass ena\n");
return;
}
@@ -3134,7 +3135,7 @@
if (adapter != NULL) {
rc = ena_rss_init_default(adapter);
adapter->rss_support = true;
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev,
"WARNING: RSS was not properly initialized,"
" it will affect bandwidth\n");
@@ -3153,7 +3154,7 @@
/* Allocate only the host info */
rc = ena_com_allocate_host_info(ena_dev);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
ena_trace(ENA_ALERT, "Cannot allocate host info\n");
return;
}
@@ -3174,7 +3175,7 @@
(DRV_MODULE_VER_SUBMINOR << ENA_ADMIN_HOST_INFO_SUB_MINOR_SHIFT);
rc = ena_com_set_host_attributes(ena_dev);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
if (rc == EOPNOTSUPP)
ena_trace(ENA_WARNING, "Cannot set host attributes\n");
else
@@ -3200,7 +3201,7 @@
int rc;
rc = ena_com_mmio_reg_read_request_init(ena_dev);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(pdev, "failed to init mmio read less\n");
return (rc);
}
@@ -3213,19 +3214,19 @@
ena_com_set_mmio_read_mode(ena_dev, readless_supported);
rc = ena_com_dev_reset(ena_dev, ENA_REGS_RESET_NORMAL);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(pdev, "Can not reset device\n");
goto err_mmio_read_less;
}
rc = ena_com_validate_version(ena_dev);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(pdev, "device version is too low\n");
goto err_mmio_read_less;
}
dma_width = ena_com_get_dma_width(ena_dev);
- if (dma_width < 0) {
+ if (unlikely(dma_width < 0)) {
device_printf(pdev, "Invalid dma width value %d", dma_width);
rc = dma_width;
goto err_mmio_read_less;
@@ -3234,7 +3235,7 @@
/* ENA admin level init */
rc = ena_com_admin_init(ena_dev, &aenq_handlers, true);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(pdev,
"Can not initialize ena admin queue with device\n");
goto err_mmio_read_less;
@@ -3251,7 +3252,7 @@
/* Get Device Attributes */
rc = ena_com_get_dev_attr_feat(ena_dev, get_feat_ctx);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(pdev,
"Cannot get attribute for ena device rc: %d\n", rc);
goto err_admin_init;
@@ -3265,7 +3266,7 @@
aenq_groups &= get_feat_ctx->aenq.supported_groups;
rc = ena_com_set_aenq_config(ena_dev, aenq_groups);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(pdev, "Cannot configure aenq groups rc: %d\n", rc);
goto err_admin_init;
}
@@ -3290,7 +3291,7 @@
int rc;
rc = ena_enable_msix(adapter);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev, "Error with MSI-X enablement\n");
return (rc);
}
@@ -3298,7 +3299,7 @@
ena_setup_mgmnt_intr(adapter);
rc = ena_request_mgmnt_irq(adapter);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev, "Cannot setup mgmnt queue intr\n");
goto err_disable_msix;
}
@@ -3342,7 +3343,7 @@
if (adapter->wd_active == 0)
return;
- if (adapter->keep_alive_timeout == 0)
+ if (likely(adapter->keep_alive_timeout == 0))
return;
timestamp = atomic_load_acq_64(&adapter->keep_alive_timestamp);
@@ -3576,7 +3577,7 @@
/* Finished destroy part. Restart the device */
rc = ena_device_init(adapter, adapter->pdev, &get_feat_ctx,
&adapter->wd_active);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev,
"ENA device init failed! (err: %d)\n", rc);
goto err_dev_free;
@@ -3584,7 +3585,7 @@
rc = ena_enable_msix_and_set_admin_interrupts(adapter,
adapter->num_queues);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev, "Enable MSI-X failed\n");
goto err_com_free;
}
@@ -3592,7 +3593,7 @@
/* If the interface was up before the reset bring it up */
if (dev_up == true) {
rc = ena_up(adapter);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(adapter->pdev,
"Failed to create I/O queues\n");
goto err_msix_free;
@@ -3656,7 +3657,7 @@
device_printf(pdev, "%s\n", ena_version);
rc = ena_allocate_pci_resources(adapter);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(pdev, "PCI resource allocation failed!\n");
ena_free_pci_resources(adapter);
return (rc);
@@ -3665,7 +3666,7 @@
/* Allocate memory for ena_dev structure */
ena_dev = malloc(sizeof(struct ena_com_dev), M_DEVBUF,
M_WAITOK | M_ZERO);
- if (ena_dev == NULL) {
+ if (unlikely(ena_dev == NULL)) {
device_printf(pdev, "allocating ena_dev failed\n");
rc = ENOMEM;
goto err_pci_free;
@@ -3675,7 +3676,7 @@
ena_dev->dmadev = pdev;
ena_dev->bus = malloc(sizeof(struct ena_bus), M_DEVBUF,
M_WAITOK | M_ZERO);
- if (ena_dev->bus == NULL) {
+ if (unlikely(ena_dev->bus == NULL)) {
device_printf(pdev, "allocating bus resources failed\n");
rc = ENOMEM;
goto err_dev_free;
@@ -3687,7 +3688,7 @@
((struct ena_bus*)(ena_dev->bus))->reg_bar_h =
rman_get_bushandle(adapter->registers);
- if (((struct ena_bus*)(ena_dev->bus))->reg_bar_h == 0) {
+ if (unlikely(((struct ena_bus*)(ena_dev->bus))->reg_bar_h == 0)) {
device_printf(pdev, "failed to pmap registers bar\n");
rc = ENXIO;
goto err_bus_free;
@@ -3697,7 +3698,7 @@
/* Device initialization */
rc = ena_device_init(adapter, pdev, &get_feat_ctx, &adapter->wd_active);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(pdev, "ENA device init failed! (err: %d)\n", rc);
rc = ENXIO;
goto err_bus_free;
@@ -3726,7 +3727,7 @@
/* calculatre ring sizes */
queue_size = ena_calc_queue_size(adapter,&tx_sgl_size,
&rx_sgl_size, &get_feat_ctx);
- if ((queue_size <= 0) || (io_queue_num <= 0)) {
+ if (unlikely((queue_size <= 0) || (io_queue_num <= 0))) {
rc = ENA_COM_FAULT;
goto err_com_free;
}
@@ -3741,30 +3742,30 @@
/* set up dma tags for rx and tx buffers */
rc = ena_setup_tx_dma_tag(adapter);
- if (rc != 0)
+ if (unlikely(rc != 0))
goto err_com_free;
rc = ena_setup_rx_dma_tag(adapter);
- if (rc != 0)
+ if (unlikely(rc != 0))
goto err_tx_tag_free;
/* initialize rings basic information */
device_printf(pdev, "initalize %d io queues\n", io_queue_num);
rc = ena_init_io_rings(adapter);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(pdev,"Error with initialization of IO rings\n");
goto err_rx_tag_free;
}
/* setup network interface */
rc = ena_setup_ifnet(pdev, adapter, &get_feat_ctx);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(pdev,"Error with network interface setup\n");
goto err_io_free;
}
rc = ena_enable_msix_and_set_admin_interrupts(adapter, io_queue_num);
- if (rc != 0) {
+ if (unlikely(rc != 0)) {
device_printf(pdev,
"Failed to enable and set the admin interrupts\n");
goto err_ifp_free;
@@ -3774,7 +3775,7 @@
TASK_INIT(&adapter->reset_task, 0, ena_reset_task, adapter);
adapter->reset_tq = taskqueue_create("ena_reset_enqueue",
M_WAITOK | M_ZERO, taskqueue_thread_enqueue, &adapter->reset_tq);
- if (adapter->reset_tq == NULL) {
+ if (unlikely(adapter->reset_tq == NULL)) {
device_printf(adapter->pdev,
"Unable to create reset task queue\n");
goto err_msix_free;
@@ -3864,16 +3865,16 @@
ena_free_counters((counter_u64_t *)&adapter->dev_stats,
sizeof(struct ena_stats_dev));
- if (adapter->rss_support == true)
+ if (likely(adapter->rss_support == true))
ena_com_rss_destroy(ena_dev);
rc = ena_free_rx_dma_tag(adapter);
- if (rc != 0)
+ if (unlikely(rc != 0))
device_printf(adapter->pdev,
"Unmapped RX DMA tag associations\n");
rc = ena_free_tx_dma_tag(adapter);
- if (rc != 0)
+ if (unlikely(rc != 0))
device_printf(adapter->pdev,
"Unmapped TX DMA tag associations\n");

File Metadata

Mime Type
text/plain
Expires
Tue, Apr 21, 2:18 AM (9 h, 46 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31875807
Default Alt Text
D12861.id34524.diff (28 KB)

Event Timeline