lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f9f82695-23aa-9835-37f5-7b6ac4d4b387@denx.de>
Date:   Wed, 25 Mar 2020 18:05:30 +0100
From:   Marek Vasut <marex@...x.de>
To:     Michal Kubecek <mkubecek@...e.cz>
Cc:     netdev@...r.kernel.org, "David S . Miller" <davem@...emloft.net>,
        Lukas Wunner <lukas@...ner.de>, Petr Stetiar <ynezz@...e.cz>,
        YueHaibing <yuehaibing@...wei.com>
Subject: Re: [PATCH V2 08/14] net: ks8851: Use 16-bit writes to program MAC
 address

On 3/25/20 5:56 PM, Michal Kubecek wrote:
> On Wed, Mar 25, 2020 at 04:05:37PM +0100, Marek Vasut wrote:
>> On the SPI variant of KS8851, the MAC address can be programmed with
>> either 8/16/32-bit writes. To make it easier to support the 16-bit
>> parallel option of KS8851 too, switch both the MAC address programming
>> and readout to 16-bit operations.
>>
>> Remove ks8851_wrreg8() as it is not used anywhere anymore.
>>
>> There should be no functional change.
>>
>> Signed-off-by: Marek Vasut <marex@...x.de>
>> Cc: David S. Miller <davem@...emloft.net>
>> Cc: Lukas Wunner <lukas@...ner.de>
>> Cc: Petr Stetiar <ynezz@...e.cz>
>> Cc: YueHaibing <yuehaibing@...wei.com>
>> ---
>> V2: Get rid of the KS_MAR(i + 1) by adjusting KS_MAR(x) macro
>> ---
> [...]
>> @@ -358,8 +329,12 @@ static int ks8851_write_mac_addr(struct net_device *dev)
>>  	 * the first write to the MAC address does not take effect.
>>  	 */
>>  	ks8851_set_powermode(ks, PMECR_PM_NORMAL);
>> -	for (i = 0; i < ETH_ALEN; i++)
>> -		ks8851_wrreg8(ks, KS_MAR(i), dev->dev_addr[i]);
>> +
>> +	for (i = 0; i < ETH_ALEN; i += 2) {
>> +		val = (dev->dev_addr[i] << 8) | dev->dev_addr[i + 1];
>> +		ks8851_wrreg16(ks, KS_MAR(i), val);
>> +	}
>> +
>>  	if (!netif_running(dev))
>>  		ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN);
>>  
>> @@ -377,12 +352,16 @@ static int ks8851_write_mac_addr(struct net_device *dev)
>>  static void ks8851_read_mac_addr(struct net_device *dev)
>>  {
>>  	struct ks8851_net *ks = netdev_priv(dev);
>> +	u16 reg;
>>  	int i;
>>  
>>  	mutex_lock(&ks->lock);
>>  
>> -	for (i = 0; i < ETH_ALEN; i++)
>> -		dev->dev_addr[i] = ks8851_rdreg8(ks, KS_MAR(i));
>> +	for (i = 0; i < ETH_ALEN; i += 2) {
>> +		reg = ks8851_rdreg16(ks, KS_MAR(i));
>> +		dev->dev_addr[i] = reg & 0xff;
>> +		dev->dev_addr[i + 1] = reg >> 8;
>> +	}
>>  
>>  	mutex_unlock(&ks->lock);
>>  }
> 
> It seems my question from v1 went unnoticed and the inconsistency still
> seems to be there so let me ask again: when writing, you put addr[i]
> into upper part of the 16-bit value and addr[i+1] into lower but when 
> reading, you do the opposite. Is it correct?

I believe so, and it works at least on the hardware I have here.
I need to wait for Lukas to verify that on KS8851 SPI edition tomorrow
(that's also why I sent out the V2, so he can test it out)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ