Date: Tue, 4 Jul 2017 00:08:47 +0000 (UTC) From: Zbigniew Bodek <zbb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320631 - head/sys/dev/ena Message-ID: <201707040008.v6408lvq083147@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: zbb Date: Tue Jul 4 00:08:47 2017 New Revision: 320631 URL: https://svnweb.freebsd.org/changeset/base/320631 Log: Fix creation of dma tags and TSO settings TSO settings were not reflecting real HW capabilities. DMA tags were created with wrong window - high address was the same as low, so excluding window was not working. Capabilities of TX dma transaction were not set properly - TSO max size had been increased and size of one segment had been adjusted. Submitted by: Michal Krawczyk <mk@semihalf.com> Obtained from: Semihalf Sponsored by: Amazon.com Inc. Modified: head/sys/dev/ena/ena.c head/sys/dev/ena/ena.h Modified: head/sys/dev/ena/ena.c ============================================================================== --- head/sys/dev/ena/ena.c Tue Jul 4 00:06:56 2017 (r320630) +++ head/sys/dev/ena/ena.c Tue Jul 4 00:08:47 2017 (r320631) @@ -226,16 +226,16 @@ ena_dma_alloc(device_t dmadev, bus_size_t size, if (dma_space_addr == 0) dma_space_addr = BUS_SPACE_MAXADDR; error = bus_dma_tag_create(bus_get_dma_tag(dmadev), /* parent */ - 8, 0, /* alignment, bounds */ - dma_space_addr, /* lowaddr */ - dma_space_addr, /* highaddr */ - NULL, NULL, /* filter, filterarg */ - maxsize, /* maxsize */ - 1, /* nsegments */ - maxsize, /* maxsegsize */ - BUS_DMA_ALLOCNOW, /* flags */ - NULL, /* lockfunc */ - NULL, /* lockarg */ + 8, 0, /* alignment, bounds */ + dma_space_addr, /* lowaddr of exclusion window */ + BUS_SPACE_MAXADDR,/* highaddr of exclusion window */ + NULL, NULL, /* filter, filterarg */ + maxsize, /* maxsize */ + 1, /* nsegments */ + maxsize, /* maxsegsize */ + BUS_DMA_ALLOCNOW, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ &dma->tag); if (error) { device_printf(dmadev, @@ -530,16 +530,16 @@ ena_setup_tx_dma_tag(struct ena_adapter *adapter) /* Create DMA tag for Tx buffers */ ret = bus_dma_tag_create(bus_get_dma_tag(adapter->pdev), - 1, 0, /* alignment, bounds */ - ENA_DMA_BIT_MASK(adapter->dma_width), /* lowaddr */ - ENA_DMA_BIT_MASK(adapter->dma_width), /* highaddr */ - NULL, NULL, /* filter, filterarg */ - ENA_TSO_MAXSIZE, /* maxsize */ - adapter->max_tx_sgl_size, /* nsegments */ - ENA_TSO_MAXSIZE, /* maxsegsize */ - 0, /* flags */ - NULL, /* lockfunc */ - NULL, /* lockfuncarg */ + 1, 0, /* alignment, bounds */ + ENA_DMA_BIT_MASK(adapter->dma_width), /* lowaddr of excl window */ + BUS_SPACE_MAXADDR, /* highaddr of excl window */ + NULL, NULL, /* filter, filterarg */ + ENA_TSO_MAXSIZE, /* maxsize */ + adapter->max_tx_sgl_size - 1, /* nsegments */ + ENA_TSO_MAXSIZE, /* maxsegsize */ + 0, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockfuncarg */ &adapter->tx_buf_tag); if (ret != 0) @@ -567,17 +567,17 @@ ena_setup_rx_dma_tag(struct ena_adapter *adapter) int ret; /* Create DMA tag for Rx buffers*/ - ret = bus_dma_tag_create(bus_get_dma_tag(adapter->pdev), /* parent */ - 1, 0, /* alignment, bounds */ - ENA_DMA_BIT_MASK(adapter->dma_width), /* lowaddr */ - ENA_DMA_BIT_MASK(adapter->dma_width), /* highaddr */ - NULL, NULL, /* filter, filterarg */ - MJUM16BYTES, /* maxsize */ - 1, /* nsegments */ - MJUM16BYTES, /* maxsegsize */ - 0, /* flags */ - NULL, /* lockfunc */ - NULL, /* lockarg */ + ret = bus_dma_tag_create(bus_get_dma_tag(adapter->pdev), /* parent */ + 1, 0, /* alignment, bounds */ + ENA_DMA_BIT_MASK(adapter->dma_width), /* lowaddr of excl window */ + BUS_SPACE_MAXADDR, /* highaddr of excl window */ + NULL, NULL, /* filter, filterarg */ + MJUM16BYTES, /* maxsize */ + 1, /* nsegments */ + MJUM16BYTES, /* maxsegsize */ + 0, /* flags */ + NULL, /* lockfunc */ + NULL, /* lockarg */ &adapter->rx_buf_tag); if (ret != 0) @@ -2479,9 +2479,10 @@ ena_setup_ifnet(device_t pdev, struct ena_adapter *ada if_setcapabilitiesbit(ifp, caps, 0); /* TSO parameters */ - ifp->if_hw_tsomax = ENA_TSO_MAXSIZE; - ifp->if_hw_tsomaxsegcount = ENA_TSO_NSEGS; - ifp->if_hw_tsomaxsegsize = MCLBYTES; + ifp->if_hw_tsomax = ENA_TSO_MAXSIZE - + (ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN); + ifp->if_hw_tsomaxsegcount = adapter->max_tx_sgl_size - 1; + ifp->if_hw_tsomaxsegsize = ENA_TSO_MAXSIZE; if_setifheaderlen(ifp, sizeof(struct ether_vlan_header)); if_setcapenable(ifp, if_getcapabilities(ifp)); Modified: head/sys/dev/ena/ena.h ============================================================================== --- head/sys/dev/ena/ena.h Tue Jul 4 00:06:56 2017 (r320630) +++ head/sys/dev/ena/ena.h Tue Jul 4 00:08:47 2017 (r320631) @@ -112,7 +112,7 @@ #define TX_IRQ_INTERVAL 50 #define ENA_MAX_MTU 9216 -#define ENA_TSO_MAXSIZE PAGE_SIZE +#define ENA_TSO_MAXSIZE 65536 #define ENA_TSO_NSEGS ENA_PKT_MAX_BUFS #define ENA_RX_OFFSET NET_SKB_PAD + NET_IP_ALIGN
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201707040008.v6408lvq083147>