All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Grzeschik <mgr@pengutronix.de>
To: Tristram.Ha@microchip.com
Cc: andrew@lunn.ch, f.fainelli@gmail.com, davem@davemloft.net,
	kernel@pengutronix.de, netdev@vger.kernel.org,
	matthias.schiffer@ew.tq-group.com, Woojung.Huh@microchip.com,
	UNGLinuxDriver@microchip.com
Subject: Re: [PATCH v5 4/6] net: dsa: microchip: ksz8795: add support for ksz88xx chips
Date: Mon, 1 Feb 2021 19:37:57 +0100	[thread overview]
Message-ID: <20210201183757.GA6935@pengutronix.de> (raw)
In-Reply-To: <BYAPR11MB35585C642A2073D0CBC85E44ECC50@BYAPR11MB3558.namprd11.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 3109 bytes --]

Hi Tristam!

On Wed, Dec 16, 2020 at 06:33:06AM +0000, Tristram.Ha@microchip.com wrote:
>>  static void ksz8_r_vlan_table(struct ksz_device *dev, u16 vid, u32 *vlan)
>>  {
>> -       int index;
>> -       u16 *data;
>> -       u16 addr;
>> +       u16 addr = vid / dev->phy_port_cnt;
>>         u64 buf;
>>
>> -       data = (u16 *)&buf;
>> -       addr = vid / dev->phy_port_cnt;
>> -       index = vid & 3;
>>         ksz8_r_table(dev, TABLE_VLAN, addr, &buf);
>> -       *vlan = data[index];
>> +       if (dev->features & IS_88X3) {
>> +               *vlan = (u32)buf;
>> +       } else {
>> +               u16 *data = (u16 *)&buf;
>> +
>> +               *vlan = data[vid & 3];
>> +       }
>>  }
>>
>>  static void ksz8_w_vlan_table(struct ksz_device *dev, u16 vid, u32 vlan)
>>  {
>> -       int index;
>> -       u16 *data;
>> -       u16 addr;
>> +       u16 addr = vid / dev->phy_port_cnt;
>>         u64 buf;
>>
>> -       data = (u16 *)&buf;
>> -       addr = vid / dev->phy_port_cnt;
>> -       index = vid & 3;
>>         ksz8_r_table(dev, TABLE_VLAN, addr, &buf);
>> -       data[index] = vlan;
>> +
>> +       if (dev->features & IS_88X3) {
>> +               buf = vlan;
>> +       } else {
>> +               u16 *data = (u16 *)&buf;
>> +
>> +               data[vid & 3] = vlan;
>> +       }
>> +
>>         dev->vlan_cache[vid].table[0] = vlan;
>>         ksz8_w_table(dev, TABLE_VLAN, addr, buf);
>>  }
>
>I am confused about how the addr is derived.
>
>In KSZ8795 vid is in range of 0-4095.  The addr is just (vid / 4) as there
>are 4 entries in one access.  The data are lined up in 16-bit boundary
>so that the VLAN information can be accessed using the array.
>
>For KSZ8895 the VLAN data are not lined up so the 64-bit variable
>needs to be shifted accordingly and masked.
>
>For KSZ8863 the addr is a hard value from 0 to 15.  The data buffer is just
>32-bit.  The vid value is contained in the entry.  You need to match that vid
>with the input vid to return the right information.
>
>You need a different VLAN read function to check if the VLAN is already
>programmed in the VLAN table by searching all 16 entries.
>
>For the VLAN write function you need to check if there is available space
>to add a new entry.  The VID range is still 0-4095, but the FID range is 0-15.

Thanks for the clarification. Its possible that I missed that when
porting this from your first RFC.

Regarding the drivers for ksz88{6,7}3, did you also plan to mainline
some work? Do you have some code that could be shared? If so I would
not need to implement everything again. In case you have some work
pending, please let me know. Than we could colaborate to get this
chips finaly mainline.

Thanks,
Michael

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2021-02-01 18:39 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 12:56 [PATCH v5 0/6] microchip: add support for ksz88x3 driver family Michael Grzeschik
2020-12-07 12:56 ` [PATCH v5 1/6] net: dsa: microchip: ksz8795: change drivers prefix to be generic Michael Grzeschik
2020-12-07 12:56 ` [PATCH v5 2/6] net: dsa: microchip: ksz8795: move cpu_select_interface to extra function Michael Grzeschik
2020-12-07 12:56 ` [PATCH v5 3/6] net: dsa: microchip: ksz8795: move register offsets and shifts to separate struct Michael Grzeschik
2020-12-07 14:11   ` kernel test robot
2020-12-07 14:11     ` kernel test robot
2020-12-07 15:01   ` David Miller
2020-12-07 20:02   ` Tristram.Ha
2020-12-07 21:44     ` Michael Grzeschik
2020-12-15 16:31       ` Michael Grzeschik
2020-12-11  4:21   ` kernel test robot
2020-12-11  4:21     ` kernel test robot
2020-12-07 12:56 ` [PATCH v5 4/6] net: dsa: microchip: ksz8795: add support for ksz88xx chips Michael Grzeschik
2020-12-16  6:33   ` Tristram.Ha
2021-02-01 18:37     ` Michael Grzeschik [this message]
2020-12-07 12:56 ` [PATCH v5 5/6] net: dsa: microchip: Add Microchip KSZ8863 SPI based driver support Michael Grzeschik
2020-12-07 12:56 ` [PATCH v5 6/6] dt-bindings: net: dsa: document additional Microchip KSZ8863/8873 switch Michael Grzeschik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210201183757.GA6935@pengutronix.de \
    --to=mgr@pengutronix.de \
    --cc=Tristram.Ha@microchip.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=Woojung.Huh@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=matthias.schiffer@ew.tq-group.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.