ena.c (3cfadb28c3f6f21cb937f7331bfa066c0edda29c) | ena.c (4727bda6f2e975a24ba6ec7a7a77cf73bf169edb) |
---|---|
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 --- 535 unchanged lines hidden (view full) --- 544 545 /* Create DMA tag for Rx buffers*/ 546 ret = bus_dma_tag_create(bus_get_dma_tag(adapter->pdev), /* parent */ 547 1, 0, /* alignment, bounds */ 548 ENA_DMA_BIT_MASK(adapter->dma_width), /* lowaddr of excl window */ 549 BUS_SPACE_MAXADDR, /* highaddr of excl window */ 550 NULL, NULL, /* filter, filterarg */ 551 MJUM16BYTES, /* maxsize */ | 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 --- 535 unchanged lines hidden (view full) --- 544 545 /* Create DMA tag for Rx buffers*/ 546 ret = bus_dma_tag_create(bus_get_dma_tag(adapter->pdev), /* parent */ 547 1, 0, /* alignment, bounds */ 548 ENA_DMA_BIT_MASK(adapter->dma_width), /* lowaddr of excl window */ 549 BUS_SPACE_MAXADDR, /* highaddr of excl window */ 550 NULL, NULL, /* filter, filterarg */ 551 MJUM16BYTES, /* maxsize */ |
552 1, /* nsegments */ | 552 adapter->max_rx_sgl_size, /* nsegments */ |
553 MJUM16BYTES, /* maxsegsize */ 554 0, /* flags */ 555 NULL, /* lockfunc */ 556 NULL, /* lockarg */ 557 &adapter->rx_buf_tag); 558 559 return (ret); 560} --- 384 unchanged lines hidden (view full) --- 945 946static inline int 947ena_alloc_rx_mbuf(struct ena_adapter *adapter, 948 struct ena_ring *rx_ring, struct ena_rx_buffer *rx_info) 949{ 950 struct ena_com_buf *ena_buf; 951 bus_dma_segment_t segs[1]; 952 int nsegs, error; | 553 MJUM16BYTES, /* maxsegsize */ 554 0, /* flags */ 555 NULL, /* lockfunc */ 556 NULL, /* lockarg */ 557 &adapter->rx_buf_tag); 558 559 return (ret); 560} --- 384 unchanged lines hidden (view full) --- 945 946static inline int 947ena_alloc_rx_mbuf(struct ena_adapter *adapter, 948 struct ena_ring *rx_ring, struct ena_rx_buffer *rx_info) 949{ 950 struct ena_com_buf *ena_buf; 951 bus_dma_segment_t segs[1]; 952 int nsegs, error; |
953 int mlen; |
|
953 954 /* if previous allocated frag is not used */ 955 if (unlikely(rx_info->mbuf != NULL)) 956 return (0); 957 958 /* Get mbuf using UMA allocator */ 959 rx_info->mbuf = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUM16BYTES); 960 961 if (unlikely(rx_info->mbuf == NULL)) { | 954 955 /* if previous allocated frag is not used */ 956 if (unlikely(rx_info->mbuf != NULL)) 957 return (0); 958 959 /* Get mbuf using UMA allocator */ 960 rx_info->mbuf = m_getjcl(M_NOWAIT, MT_DATA, M_PKTHDR, MJUM16BYTES); 961 962 if (unlikely(rx_info->mbuf == NULL)) { |
962 counter_u64_add(rx_ring->rx_stats.mbuf_alloc_fail, 1); 963 return (ENOMEM); | 963 counter_u64_add(rx_ring->rx_stats.mjum_alloc_fail, 1); 964 rx_info->mbuf = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR); 965 if (unlikely(rx_info->mbuf == NULL)) { 966 counter_u64_add(rx_ring->rx_stats.mbuf_alloc_fail, 1); 967 return (ENOMEM); 968 } 969 mlen = MCLBYTES; 970 } else { 971 mlen = MJUM16BYTES; |
964 } 965 /* Set mbuf length*/ | 972 } 973 /* Set mbuf length*/ |
966 rx_info->mbuf->m_pkthdr.len = rx_info->mbuf->m_len = MJUM16BYTES; | 974 rx_info->mbuf->m_pkthdr.len = rx_info->mbuf->m_len = mlen; |
967 968 /* Map packets for DMA */ 969 ena_trace(ENA_DBG | ENA_RSC | ENA_RXPTH, 970 "Using tag %p for buffers' DMA mapping, mbuf %p len: %d", 971 adapter->rx_buf_tag,rx_info->mbuf, rx_info->mbuf->m_len); 972 error = bus_dmamap_load_mbuf_sg(adapter->rx_buf_tag, rx_info->map, 973 rx_info->mbuf, segs, &nsegs, BUS_DMA_NOWAIT); 974 if (unlikely((error != 0) || (nsegs != 1))) { 975 ena_trace(ENA_WARNING, "failed to map mbuf, error: %d, " 976 "nsegs: %d\n", error, nsegs); 977 counter_u64_add(rx_ring->rx_stats.dma_mapping_err, 1); 978 goto exit; 979 980 } 981 982 bus_dmamap_sync(adapter->rx_buf_tag, rx_info->map, BUS_DMASYNC_PREREAD); 983 984 ena_buf = &rx_info->ena_buf; 985 ena_buf->paddr = segs[0].ds_addr; | 975 976 /* Map packets for DMA */ 977 ena_trace(ENA_DBG | ENA_RSC | ENA_RXPTH, 978 "Using tag %p for buffers' DMA mapping, mbuf %p len: %d", 979 adapter->rx_buf_tag,rx_info->mbuf, rx_info->mbuf->m_len); 980 error = bus_dmamap_load_mbuf_sg(adapter->rx_buf_tag, rx_info->map, 981 rx_info->mbuf, segs, &nsegs, BUS_DMA_NOWAIT); 982 if (unlikely((error != 0) || (nsegs != 1))) { 983 ena_trace(ENA_WARNING, "failed to map mbuf, error: %d, " 984 "nsegs: %d\n", error, nsegs); 985 counter_u64_add(rx_ring->rx_stats.dma_mapping_err, 1); 986 goto exit; 987 988 } 989 990 bus_dmamap_sync(adapter->rx_buf_tag, rx_info->map, BUS_DMASYNC_PREREAD); 991 992 ena_buf = &rx_info->ena_buf; 993 ena_buf->paddr = segs[0].ds_addr; |
986 ena_buf->len = MJUM16BYTES; | 994 ena_buf->len = mlen; |
987 988 ena_trace(ENA_DBG | ENA_RSC | ENA_RXPTH, 989 "ALLOC RX BUF: mbuf %p, rx_info %p, len %d, paddr %#jx\n", 990 rx_info->mbuf, rx_info,ena_buf->len, (uintmax_t)ena_buf->paddr); 991 992 return (0); 993 994exit: --- 2947 unchanged lines hidden --- | 995 996 ena_trace(ENA_DBG | ENA_RSC | ENA_RXPTH, 997 "ALLOC RX BUF: mbuf %p, rx_info %p, len %d, paddr %#jx\n", 998 rx_info->mbuf, rx_info,ena_buf->len, (uintmax_t)ena_buf->paddr); 999 1000 return (0); 1001 1002exit: --- 2947 unchanged lines hidden --- |