From owner-freebsd-arm@freebsd.org Wed Sep 27 21:50:10 2017 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E8458E10497 for ; Wed, 27 Sep 2017 21:50:10 +0000 (UTC) (envelope-from guyyur@gmail.com) Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 882EC3586 for ; Wed, 27 Sep 2017 21:50:10 +0000 (UTC) (envelope-from guyyur@gmail.com) Received: by mail-wm0-x242.google.com with SMTP id r136so337141wmf.2 for ; Wed, 27 Sep 2017 14:50:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=HNPp7EiopwxzzbLvxKdVLuAIVDTgWMLCcHnwq6jZ/lc=; b=vOA39duFisTRnMHIjMlafjtZvwx5yHfQHm56WJcklTJoeIkBqkAB8bxmmLJWcRIS51 IchoH4aMsUccCf7RYJK3WxP6ir7tXCeNsK8j9LC+vGckU1vCkEbZNjXt9/K69zFLqg4D zOEDVr9DTOs2uoVPWVP2TQJbJoxE3PW4+v+kuMQSpnu5D464RR+snsedEkRkew0tRrkt FQIZ5eI5o39tIiHipi9t7sp3FrtL5/EdqWudXbj3M2UHYpfk2lFNQgjqf7rruEb7K92c F0v07R0rnHuW8RzfFzVZVYoaG96ClVMcrH1nDeemuobhZy6hSNqA9ia5CVqZKPMlN6EL v99w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=HNPp7EiopwxzzbLvxKdVLuAIVDTgWMLCcHnwq6jZ/lc=; b=khIaE5MBxzMiLEvu8qcTfPfAjiyGKWh13usaaADH1q7dkyqhgDW2yVnXg6XZCl7twx ue6ndnUqUGwLaxh8NYIh4JcpMCiBoShYFjRPHBoeGoTj9reqU+8HEuvNBZwZTroRJMPd 3vQUu4/OOHCBvpSRcMGJZhs5eIHJMcl2t7zFWSFjP0LEJxWseh65JGYpvCo1FUV2zGV7 T3ZyRWO7tDPDqrWDLC9EuA2iCOwcbPT2WxaCuKqRk/hVYgSsVvk8xwx7S0kUwzxFuXTt 3FXN+dRwrNNwqpsMP3zt+4SFPrq4MRzp46K11ble1urlbR4GLWPqmtIpHZCi3wMQM60N oKAg== X-Gm-Message-State: AHPjjUiewBq/EGvPLoj195lfmmRW9vtsm5+BlsQuepAUTR8x+427ZCMp aJqQMXZ4Njg/c6fD2MxM5pPZLfp0BB7K3MYiX414uA== X-Google-Smtp-Source: AOwi7QDoCx6RL0e4UcSW6hWxVbMFjvurdSH1gI2E2PcdKfAmUgcZuNuv83PqHondO2rwvVvfK7FVINVGVPnGIXG0cnc= X-Received: by 10.28.210.5 with SMTP id j5mr1326280wmg.15.1506549008590; Wed, 27 Sep 2017 14:50:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.238.142 with HTTP; Wed, 27 Sep 2017 14:50:07 -0700 (PDT) From: Guy Yur Date: Thu, 28 Sep 2017 00:50:07 +0300 Message-ID: Subject: if_awg fixes To: freebsd-arm Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Sep 2017 21:50:11 -0000 Hi, I had issues with if_awg when passing heavy traffic (transmission, samba, ...) a. The tx hardware checksum stopped working after a while. IPv4 packets were sent with IP and TCP/UDO checksum fields unmodified. so the packets were rejected by the receiving host. IPv4 checksum was 0 and TCP/UDP checksum only pseudo header. IPv6 packets were fine since the card doesn't do offload for ipv6. b. mbuf leaks. "current" mbuf clusters count kept rising in "netstat -m" for some traffic types and never went down until eventually reaching max. Comparing the driver against if_nfe which also uses a ring buffer, there are several issues with how the rings are programmed. I made changes inspired by it. The following fixes improved the card behavior on my boards. (tested on Orange Pi PC and Orange Pi One) 1. https://github.com/guyyur/freebsd-src_patches/blob/master/if_awg_fixes_1_reg_offsets.patch Wrong register offsets for the tx_dma status regs. Registers are currently only used when dumping them (AWG_DEBUG defined and doing soft reset). 2. https://github.com/guyyur/freebsd-src_patches/blob/master/if_awg_fixes_2_fix_txcsum_disabled.patch Fix behavior when txcsum is disabled by turning CSUM_UDP and CSUM_TCP on/off along with CSUM_IP. Only consider IFCAP_TXCSUM to set/unset CSUM_* since the flags are only checked in tx path. IFCAP_RXCSUM is checked in rx path. CSUM_IP is independent from CSUM_UDP and CSUM_TCP. If only CSUM_IP is turned off but CSUM_UDP and CSUM_TCP are set the card will not compute the checksum but the OS expects the tcp/udp field to be hw computed. 3. https://github.com/guyyur/freebsd-src_patches/blob/master/if_awg_fixes_3_fix_tx_path.patch Fix tx programming when there are multiple segments. a. Set TX_DESC_CTL on the first descriptor only after all the other descriptors have been programmed. This will prevent the card from advancing on the first descriptor while the other descriptors are still being written. b. Put the mbuf and map for release on the last segment. The map from the first segment is used so swap it with the last. The data sheet mentions the descriptors are marked as done only after the frame is transmitted so it might be fine to keep the map and mbuf in the first segment but it doesn't hurt to keep it in the last. c. if m_collapse fails, release the buffer instead of enqueuing it again where it will keep failing. 4. https://github.com/guyyur/freebsd-src_patches/blob/master/if_awg_fixes_4_rx_avoid_holes.patch Avoid hole in the rx ring by keeping a spare dma map. If new mbuf allocation or dma mapping fails, just reuse the existing mbuf and increase the drop counter. Only try to allocate a new buffer if len of packet > 0. If there were errors or just an empty packet, reuse the buffer. 5. https://github.com/guyyur/freebsd-src_patches/blob/master/if_awg_fixes_5_cleanup_buffers_on_stop.patch Cleanup tx and rx buffers on card stop. ifconfig ... down ifconfig ... up tx and rx indices are advanced to where the card expects the next buffer. I don't see a way to reset the dma_cur_desc regs mentioned in the data sheet. Thanks, Guy