From owner-freebsd-wireless@freebsd.org Sun Oct 1 18:51:07 2017 Return-Path: Delivered-To: freebsd-wireless@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 C6A27E2BEE6 for ; Sun, 1 Oct 2017 18:51:07 +0000 (UTC) (envelope-from khanzf@gmail.com) Received: from mail-qt0-x22a.google.com (mail-qt0-x22a.google.com [IPv6:2607:f8b0:400d:c0d::22a]) (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 7E3916AC2E for ; Sun, 1 Oct 2017 18:51:07 +0000 (UTC) (envelope-from khanzf@gmail.com) Received: by mail-qt0-x22a.google.com with SMTP id s18so5011327qta.3 for ; Sun, 01 Oct 2017 11:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=6fcXxcKNZSnnn9XYhJpsVgdDfvWnJvtp1QR5QsQ79BY=; b=MKH5MjQNt5a3/O3ulhAVjCCj7spCgKf3iunGUP9wvFBcTpt7CaihnsTcIjDzS0wq2/ E+N/tBp6kjTMUbimvWeio2zC808LwKCLWx9PsvxbKz8SxtinY1iKq34Ago4hkTNZ8L2L kFNN69Wr3dUe4cnzXWxgRueKX089V1kcBk9IhnmCwJ9AT+lkIvRqxxdrNm7G07ZmB3mh /xgUmVKiuhfekOQQV+vHbKBtNfeqKt4hFSHAdxpo71OCQ0G35mJi1NHaPhNq6xPlJNxH Ep/YOG99TzGDRbqX+d5PSBeFnqmyJhjaPb3igWsrJfzZKS7XL8OJ2SLeU+jWuDybWdo4 2X6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=6fcXxcKNZSnnn9XYhJpsVgdDfvWnJvtp1QR5QsQ79BY=; b=QasKgJV3nvNi31z6N/nOTKc57qgnlAt0VRapxIIlz4GGpXryuzS30MWcMGz47GsyFu 5oSKu3lNZdP9Vd1X0LnDBA/7YKenjwDCc4EUja9nmB4Hfc+unHVDLD8UKyX7yVd1AB3t wSfAF4ngSGWgiSD1BEbsyn7qQ5jSEQm7FXBXKVvmqI09poHwKGAhg56zAMCfVy+sHrGM 8j9wa8a+znJqUl6oODIm3aGxqy0zXD8ZV0sz+/gvpogv10mbFkBdiB7gq6hnuqRE/LhT 6zLVcmv6y9253vEGmKXnveB6BtXOm2BlIXrLo9TrgmwCmxbWke0HwPudDXJwgmWdbEDM v4Kg== X-Gm-Message-State: AMCzsaVJ4y1SmWjEA/1in7Cdu5xhYf1sVLuQxqFzMsxgKXDyDnG5Hpke RZZC3H0OyzsHh9T7tsFngaUGuJ49 X-Google-Smtp-Source: AOwi7QDjIxSQdjj3CAcE4RTMJGGfkohxa3MFvkqc7eC0cltfJueGPuFFPwlzCuAEkJkP+vZak3k5nw== X-Received: by 10.237.34.181 with SMTP id p50mr15880261qtc.192.1506883866348; Sun, 01 Oct 2017 11:51:06 -0700 (PDT) Received: from pc.farhan.codes ([2001:470:8:209:ee25:a59b:55f4:7cc]) by smtp.gmail.com with ESMTPSA id e68sm2012265qtb.23.2017.10.01.11.51.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Oct 2017 11:51:04 -0700 (PDT) Subject: Re: Register Address Size Mismatch To: Andriy Voskoboinyk Cc: freebsd-wireless@freebsd.org References: <293228d3-c777-d928-8476-ee23ba487c72@gmail.com> From: Farhan Khan Message-ID: <3f760297-d8dd-a2e0-9fda-e09bff06b11c@gmail.com> Date: Sun, 1 Oct 2017 14:51:04 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Oct 2017 18:51:07 -0000 The issue is in the assignment, not the write/read part. rtwn_rf_prog wants a * uint8_t list, whereas the register size from Linux is a uint32_t (but can cleanly fit into a uint16_t and might just be the default register size on Linux). How do I reconcile those two? I hope I was clearer there. The first column are the Linux registers in question: http://src.illumos.org/source/xref/linux-master/drivers/net/wireless/realtek/rtlwifi/rtl8188ee/table.c#316 Thank you for your continued assistance. On 10/01/2017 06:30 AM, Andriy Voskoboinyk wrote: > Hi, > > RF registers are using indirect addressing; you should use > rtwn_rf_write() / rtwn_rf_read() instead. > > >> I am working on porting over a Linux Realtek driver to FreeBSD. I ran >> into a register-size issue. >> >> FreeBSD's PCI-write function is defined as follows: >> rtwn_pci_write_4(struct rtwn_softc *sc, uint16_t addr) >> >> Notice that the second parameter is of type uint16_t. >> >> During initialization, the rtwn driver uses the rtwn_rf_prog structure >> to write a pre-defined list of data to a pre-defined list of registers. >> The structure to hold both lists is defined here: >> http://src.illumos.org/source/xref/freebsd-head/sys/dev/rtwn/if_rtwnreg.h#150. >> >> Notice how the second parameter 'reg' is a uint8_t. >> >> The rtwn_pci_write_4's addr is uint16_t, the rtwn_rf_prog's addr is a >> uint8_t. How would I reconcile this type mismatch? Additionally, the >> Linux version of this block of code has all register values as a >> uint32_t. It is not a matter of a cast, because some values definitely >> use more than 1 byte (ie 0xFFE). >> >> Suggestions on how to reconcile and resolve this issue? >> >> Thanks! >> Farhan Khan >> _______________________________________________ >> freebsd-wireless@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/freebsd-wireless >> To unsubscribe, send any mail to >> "freebsd-wireless-unsubscribe@freebsd.org"