ena.c (4c220feb7e700d1d83323f38345ea85fb587912d) | ena.c (c51a229ca754eba7e83a4a5e8c18a3517263ba2f) |
---|---|
1/*- 2 * BSD LICENSE 3 * 4 * Copyright (c) 2015-2017 Amazon.com, Inc. or its affiliates. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 1032 unchanged lines hidden (view full) --- 1041 1042 for (i = 0; i < num; i++) { 1043 struct ena_rx_buffer *rx_info; 1044 1045 ena_trace(ENA_DBG | ENA_RXPTH | ENA_RSC, 1046 "RX buffer - next to use: %d", next_to_use); 1047 1048 req_id = rx_ring->free_rx_ids[next_to_use]; | 1/*- 2 * BSD LICENSE 3 * 4 * Copyright (c) 2015-2017 Amazon.com, Inc. or its affiliates. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 1032 unchanged lines hidden (view full) --- 1041 1042 for (i = 0; i < num; i++) { 1043 struct ena_rx_buffer *rx_info; 1044 1045 ena_trace(ENA_DBG | ENA_RXPTH | ENA_RSC, 1046 "RX buffer - next to use: %d", next_to_use); 1047 1048 req_id = rx_ring->free_rx_ids[next_to_use]; |
1049 rc = validate_rx_req_id(rx_ring, req_id); 1050 if (unlikely(rc != 0)) 1051 break; 1052 | |
1053 rx_info = &rx_ring->rx_buffer_info[req_id]; 1054 1055 rc = ena_alloc_rx_mbuf(adapter, rx_ring, rx_info); 1056 if (unlikely(rc != 0)) { 1057 ena_trace(ENA_WARNING, 1058 "failed to alloc buffer for rx queue %d\n", 1059 rx_ring->qid); 1060 break; --- 406 unchanged lines hidden (view full) --- 1467static struct mbuf* 1468ena_rx_mbuf(struct ena_ring *rx_ring, struct ena_com_rx_buf_info *ena_bufs, 1469 struct ena_com_rx_ctx *ena_rx_ctx, uint16_t *next_to_clean) 1470{ 1471 struct mbuf *mbuf; 1472 struct ena_rx_buffer *rx_info; 1473 struct ena_adapter *adapter; 1474 unsigned int descs = ena_rx_ctx->descs; | 1049 rx_info = &rx_ring->rx_buffer_info[req_id]; 1050 1051 rc = ena_alloc_rx_mbuf(adapter, rx_ring, rx_info); 1052 if (unlikely(rc != 0)) { 1053 ena_trace(ENA_WARNING, 1054 "failed to alloc buffer for rx queue %d\n", 1055 rx_ring->qid); 1056 break; --- 406 unchanged lines hidden (view full) --- 1463static struct mbuf* 1464ena_rx_mbuf(struct ena_ring *rx_ring, struct ena_com_rx_buf_info *ena_bufs, 1465 struct ena_com_rx_ctx *ena_rx_ctx, uint16_t *next_to_clean) 1466{ 1467 struct mbuf *mbuf; 1468 struct ena_rx_buffer *rx_info; 1469 struct ena_adapter *adapter; 1470 unsigned int descs = ena_rx_ctx->descs; |
1471 int rc; |
|
1475 uint16_t ntc, len, req_id, buf = 0; 1476 1477 ntc = *next_to_clean; 1478 adapter = rx_ring->adapter; 1479 rx_info = &rx_ring->rx_buffer_info[ntc]; 1480 1481 if (unlikely(rx_info->mbuf == NULL)) { 1482 device_printf(adapter->pdev, "NULL mbuf in rx_info"); 1483 return (NULL); 1484 } 1485 1486 len = ena_bufs[buf].len; 1487 req_id = ena_bufs[buf].req_id; | 1472 uint16_t ntc, len, req_id, buf = 0; 1473 1474 ntc = *next_to_clean; 1475 adapter = rx_ring->adapter; 1476 rx_info = &rx_ring->rx_buffer_info[ntc]; 1477 1478 if (unlikely(rx_info->mbuf == NULL)) { 1479 device_printf(adapter->pdev, "NULL mbuf in rx_info"); 1480 return (NULL); 1481 } 1482 1483 len = ena_bufs[buf].len; 1484 req_id = ena_bufs[buf].req_id; |
1485 rc = validate_rx_req_id(rx_ring, req_id); 1486 if (unlikely(rc != 0)) 1487 return (NULL); 1488 |
|
1488 rx_info = &rx_ring->rx_buffer_info[req_id]; 1489 1490 ena_trace(ENA_DBG | ENA_RXPTH, "rx_info %p, mbuf %p, paddr %jx", 1491 rx_info, rx_info->mbuf, (uintmax_t)rx_info->ena_buf.paddr); 1492 1493 mbuf = rx_info->mbuf; 1494 mbuf->m_flags |= M_PKTHDR; 1495 mbuf->m_pkthdr.len = len; --- 16 unchanged lines hidden (view full) --- 1512 /* 1513 * While we have more than 1 descriptors for one rcvd packet, append 1514 * other mbufs to the main one 1515 */ 1516 while (--descs) { 1517 ++buf; 1518 len = ena_bufs[buf].len; 1519 req_id = ena_bufs[buf].req_id; | 1489 rx_info = &rx_ring->rx_buffer_info[req_id]; 1490 1491 ena_trace(ENA_DBG | ENA_RXPTH, "rx_info %p, mbuf %p, paddr %jx", 1492 rx_info, rx_info->mbuf, (uintmax_t)rx_info->ena_buf.paddr); 1493 1494 mbuf = rx_info->mbuf; 1495 mbuf->m_flags |= M_PKTHDR; 1496 mbuf->m_pkthdr.len = len; --- 16 unchanged lines hidden (view full) --- 1513 /* 1514 * While we have more than 1 descriptors for one rcvd packet, append 1515 * other mbufs to the main one 1516 */ 1517 while (--descs) { 1518 ++buf; 1519 len = ena_bufs[buf].len; 1520 req_id = ena_bufs[buf].req_id; |
1521 rc = validate_rx_req_id(rx_ring, req_id); 1522 if (unlikely(rc != 0)) { 1523 /* 1524 * If the req_id is invalid, then the device will be 1525 * reset. In that case we must free all mbufs that 1526 * were already gathered. 1527 */ 1528 m_freem(mbuf); 1529 return (NULL); 1530 } |
|
1520 rx_info = &rx_ring->rx_buffer_info[req_id]; 1521 1522 if (unlikely(rx_info->mbuf == NULL)) { 1523 device_printf(adapter->pdev, "NULL mbuf in rx_info"); 1524 /* 1525 * If one of the required mbufs was not allocated yet, 1526 * we can break there. 1527 * All earlier used descriptors will be reallocated --- 2428 unchanged lines hidden --- | 1531 rx_info = &rx_ring->rx_buffer_info[req_id]; 1532 1533 if (unlikely(rx_info->mbuf == NULL)) { 1534 device_printf(adapter->pdev, "NULL mbuf in rx_info"); 1535 /* 1536 * If one of the required mbufs was not allocated yet, 1537 * we can break there. 1538 * All earlier used descriptors will be reallocated --- 2428 unchanged lines hidden --- |