netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander H Duyck <alexander.duyck@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: netdev@vger.kernel.org, Alexander Duyck <alexanderduyck@fb.com>,
	 kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com
Subject: Re: [net-next PATCH 11/15] eth: fbnic: Enable Ethernet link setup
Date: Mon, 22 Apr 2024 11:59:13 -0700	[thread overview]
Message-ID: <c3c155131582acf447ed0a370bf4e7701c76b425.camel@gmail.com> (raw)
In-Reply-To: <bffafcca-3b02-4f76-929b-fc5e30284c2b@lunn.ch>

On Mon, 2024-04-22 at 17:52 +0200, Andrew Lunn wrote:
> On Sun, Apr 21, 2024 at 04:21:57PM -0700, Alexander Duyck wrote:
> > On Fri, Apr 5, 2024 at 2:51 PM Andrew Lunn <andrew@lunn.ch> wrote:
> > > 
> > > > +#define FBNIC_CSR_START_PCS          0x10000 /* CSR section delimiter */
> > > > +#define FBNIC_PCS_CONTROL1_0         0x10000         /* 0x40000 */
> > > > +#define FBNIC_PCS_CONTROL1_RESET             CSR_BIT(15)
> > > > +#define FBNIC_PCS_CONTROL1_LOOPBACK          CSR_BIT(14)
> > > > +#define FBNIC_PCS_CONTROL1_SPEED_SELECT_ALWAYS       CSR_BIT(13)
> > > > +#define FBNIC_PCS_CONTROL1_SPEED_ALWAYS              CSR_BIT(6)
> > > 
> > > This appears to be PCS control register 1, define in 45.2.3.1. Since
> > > this is a standard register, please add it to mdio.h.
> > 
> > Actually all these bits are essentially there in the forms of:
> > MDIO_CTRL1_RESET, MDIO_PCS_CTRL1_LOOPBACK, and MDIO_CTRL1_SPEEDSELEXT.
> > I will base the driver on these values.
> 
> Great, thanks.
> 
> > > > +#define FBNIC_PCS_VENDOR_VL_INTVL_0  0x10202         /* 0x40808 */
> > > 
> > > Could you explain how these registers map to 802.3 clause 45? Would
> > > that be 3.1002? That would however put it in the reserved range 3.812
> > > through 3.1799. The vendor range is 3.32768 through 3.65535.
> > 
> > So from what I can tell the vendor specific registers are mapped into
> > the middle of the range starting at register 512 instead of starting
> > at 32768.
> 
> 802.3, clause 1.4.512:
> 
>   reserved: A key word indicating an object (bit, register, connector
>   pin, encoding, interface signal, enumeration, etc.) to be defined
>   only by this standard. A reserved object shall not be used for any
>   user- defined purpose such as a user- or device-specific function;
>   and such use of a reserved object shall render the implementation
>   noncompliant with this standard.
> 
> It is surprising how many vendors like to make their devices
> noncompliant by not following simple things like this. Anyway, nothing
> you can do. Please put _VEND_ in the #define names to make it clear
> these are vendor registers, even if they are not in the vendor space.

Yeah, I am not sure how much of this is the synthesis of the IP versus
the mapping functionality of our device in terms of how the registers
got ordered. I'm thinking if nothing else there may be a need to break
this up into logical "pages".

From what I can tell the layout is something like:
CSR Range	Register Block
==================================
   0 -  511	PCS Channel 0 (within spec)
 512 - 1023	PCS Channel 0 Vendor Registers
1024 - 1535	PCS Channel 1 (within spec)
1536 - 2043	PCS Channel 1 Vendor Registers

I said we weren't using channel 1 registers but after looking back
through the code and starting re-factoring I believe I was thinking of
channels 2 and 3 which would be used for 100-R4. Basically channel 1 is
used in the 50-R2 and 100-R2 use cases.

As far as the vendor registers themselves most of this block of
registers is all about the virtual lane alignment markers. As such I
may want to export the values to a shared header file since they should
be common as per the spec, but the means of programming them would be
vendor specific.

> > > > +#define FBNIC_CSR_START_RSFEC                0x10800 /* CSR section delimiter */
> > > > +#define FBNIC_RSFEC_CONTROL(n)\
> > > > +                             (0x10800 + 8 * (n))     /* 0x42000 + 32*n */
> > > > +#define FBNIC_RSFEC_CONTROL_AM16_COPY_DIS    CSR_BIT(3)
> > > > +#define FBNIC_RSFEC_CONTROL_KP_ENABLE                CSR_BIT(8)
> > > > +#define FBNIC_RSFEC_CONTROL_TC_PAD_ALTER     CSR_BIT(10)
> > > > +#define FBNIC_RSFEC_MAX_LANES                        4
> > > > +#define FBNIC_RSFEC_CCW_LO(n) \
> > > > +                             (0x10802 + 8 * (n))     /* 0x42008 + 32*n */
> > > > +#define FBNIC_RSFEC_CCW_HI(n) \
> > > > +                             (0x10803 + 8 * (n))     /* 0x4200c + 32*n */
> > > 
> > > Is this Corrected Code Words Lower/Upper? 1.202 and 1.203?
> > 
> > Yes and no, this is 3.802 and 3.803 which I assume is more or less the
> > same thing but the PCS variant.
> 
> Have you figure out how to map the 802.3 register number to the value
> you need here? 0x42008 + 32*n? Ideally we should list the registers in
> the common header file with there 802.3 defined value. Your driver can
> them massage the value to what you need for your memory mapped device.

Similarly for the RSFEC portion things seem to have been broken out
into 4 blocks w/ multiple sets of registers. The first 6 are laid out
in the same order as the spec, but they are starting at an offset of
(2048 + 8 * (n)) instead of 800. So I suppose the big question would be
how to convert the standard addressing scheme into something that would
get us to the right page for the right interface.

> If you really want to go the whole hog, you might be able to extend
> mdio-regmap.c to support memory mapped C45 registers, so your driver
> can then use mdiodev_c45_read()/mdiodev_c45_write(). We have a few PCS
> drivers for licensed IP which appear on both MDIO busses and memory
> mapped. mdio-regmap.c hides way the access details.

The big issue as I see it is the fact that we have multiple copies of
things that are interleaved together. So for example with the RSFEC we
have 4 blocks of 8 registers that are all interleaved with the first 6
matching the layout, but the last 2 being something different.

Since I am not accessing these via MDIO I am not sure what the expected
layout should be in terms of deciding what should be a device, channel,
or register address and how that would map to a page.

  reply	other threads:[~2024-04-22 18:59 UTC|newest]

Thread overview: 163+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-03 20:08 [net-next PATCH 00/15] eth: fbnic: Add network driver for Meta Platforms Host Network Interface Alexander Duyck
2024-04-03 20:08 ` [net-next PATCH 01/15] PCI: Add Meta Platforms vendor ID Alexander Duyck
2024-04-03 20:20   ` Bjorn Helgaas
2024-04-03 20:08 ` [net-next PATCH 02/15] eth: fbnic: add scaffolding for Meta's NIC driver Alexander Duyck
2024-04-03 20:33   ` Andrew Lunn
2024-04-03 20:47     ` Alexander Duyck
2024-04-03 21:17       ` Andrew Lunn
2024-04-03 21:51         ` Alexander Duyck
2024-04-03 22:20           ` Andrew Lunn
2024-04-03 23:27             ` Alexander Duyck
2024-04-03 20:08 ` [net-next PATCH 03/15] eth: fbnic: Allocate core device specific structures and devlink interface Alexander Duyck
2024-04-03 20:35   ` Bjorn Helgaas
2024-04-03 20:08 ` [net-next PATCH 04/15] eth: fbnic: Add register init to set PCIe/Ethernet device config Alexander Duyck
2024-04-03 20:46   ` Andrew Lunn
2024-04-10 20:31     ` Jacob Keller
2024-04-03 20:08 ` [net-next PATCH 05/15] eth: fbnic: add message parsing for FW messages Alexander Duyck
2024-04-03 21:07   ` Jeff Johnson
2024-04-03 20:08 ` [net-next PATCH 06/15] eth: fbnic: add FW communication mechanism Alexander Duyck
2024-04-03 20:08 ` [net-next PATCH 07/15] eth: fbnic: allocate a netdevice and napi vectors with queues Alexander Duyck
2024-04-03 20:58   ` Andrew Lunn
2024-04-03 22:15     ` Alexander Duyck
2024-04-03 22:26       ` Andrew Lunn
2024-04-03 20:08 ` [net-next PATCH 08/15] eth: fbnic: implement Tx queue alloc/start/stop/free Alexander Duyck
2024-04-03 20:09 ` [net-next PATCH 09/15] eth: fbnic: implement Rx " Alexander Duyck
2024-04-04 11:42   ` kernel test robot
2024-04-03 20:09 ` [net-next PATCH 10/15] eth: fbnic: Add initial messaging to notify FW of our presence Alexander Duyck
2024-04-03 20:09 ` [net-next PATCH 11/15] eth: fbnic: Enable Ethernet link setup Alexander Duyck
2024-04-03 21:11   ` Andrew Lunn
2024-04-05 21:51   ` Andrew Lunn
2024-04-21 23:21     ` Alexander Duyck
2024-04-22 15:52       ` Andrew Lunn
2024-04-22 18:59         ` Alexander H Duyck [this message]
2024-04-03 20:09 ` [net-next PATCH 12/15] eth: fbnic: add basic Tx handling Alexander Duyck
2024-04-03 20:09 ` [net-next PATCH 13/15] eth: fbnic: add basic Rx handling Alexander Duyck
2024-04-09 11:47   ` Yunsheng Lin
2024-04-09 15:08     ` Alexander Duyck
2024-04-10 11:54       ` Yunsheng Lin
2024-04-10 15:03         ` Alexander Duyck
2024-04-12  8:43           ` Yunsheng Lin
2024-04-12  9:47             ` Yunsheng Lin
2024-04-12 15:05             ` Alexander Duyck
2024-04-15 13:19               ` Yunsheng Lin
2024-04-15 15:03                 ` Alexander Duyck
2024-04-15 17:11                   ` Jakub Kicinski
2024-04-15 18:03                     ` Alexander Duyck
2024-04-15 18:19                       ` Jakub Kicinski
2024-04-15 18:55                         ` Alexander Duyck
2024-04-15 22:01                           ` Jakub Kicinski
2024-04-15 23:57                             ` Alexander Duyck
2024-04-16  0:24                               ` Jakub Kicinski
2024-04-16 13:25                             ` Yunsheng Lin
2024-04-16 14:35                               ` Alexander Duyck
2024-04-16 14:05                       ` Alexander Lobakin
2024-04-16 14:46                         ` Alexander Duyck
2024-04-16 18:26                           ` Andrew Lunn
2024-04-17  8:14                           ` Leon Romanovsky
2024-04-17 16:09                             ` Alexander Duyck
2024-04-17 10:39                           ` Alexander Lobakin
2024-04-03 20:09 ` [net-next PATCH 14/15] eth: fbnic: add L2 address programming Alexander Duyck
2024-04-03 20:09 ` [net-next PATCH 15/15] eth: fbnic: write the TCAM tables used for RSS control and Rx to host Alexander Duyck
2024-04-03 20:42 ` [net-next PATCH 00/15] eth: fbnic: Add network driver for Meta Platforms Host Network Interface Bjorn Helgaas
2024-04-04 11:37 ` Jiri Pirko
2024-04-04 14:45   ` Alexander Duyck
2024-04-04 15:24     ` Andrew Lunn
2024-04-04 15:37       ` Jakub Kicinski
2024-04-05  3:08         ` David Ahern
2024-04-04 15:36     ` Jiri Pirko
2024-04-04 18:35       ` Andrew Lunn
2024-04-04 19:05         ` Leon Romanovsky
2024-04-04 19:22       ` Alexander Duyck
2024-04-04 20:25         ` Jakub Kicinski
2024-04-04 21:59           ` John Fastabend
2024-04-04 23:50             ` Jakub Kicinski
2024-04-05  0:11               ` Alexander Duyck
2024-04-05  2:38                 ` Jakub Kicinski
2024-04-05 15:41                   ` Alexander Duyck
2024-04-08  6:18                     ` Leon Romanovsky
2024-04-08 15:26                       ` Alexander Duyck
2024-04-08 18:41                         ` Leon Romanovsky
2024-04-08 20:43                           ` Alexander Duyck
2024-04-08 21:49                             ` Florian Fainelli
2024-04-08 21:52                               ` Florian Fainelli
2024-04-09  8:18                             ` Leon Romanovsky
2024-04-09 14:43                               ` Alexander Duyck
2024-04-09 15:39                                 ` Jason Gunthorpe
2024-04-09 16:31                                   ` Alexander Duyck
2024-04-09 17:12                                     ` Jason Gunthorpe
2024-04-09 18:38                                       ` Alexander Duyck
2024-04-09 18:54                                         ` Jason Gunthorpe
2024-04-09 20:03                                           ` Alexander Duyck
2024-04-09 23:11                                             ` Jason Gunthorpe
2024-04-10  9:37                                             ` Jiri Pirko
2024-04-09 19:15                                         ` Leon Romanovsky
2024-04-05  7:11                 ` Paolo Abeni
2024-04-05 12:26                   ` Jason Gunthorpe
2024-04-05 13:06                     ` Daniel Borkmann
2024-04-05 14:24                     ` Alexander Duyck
2024-04-05 15:17                       ` Jason Gunthorpe
2024-04-05 18:38                         ` Alexander Duyck
2024-04-05 19:02                           ` Jason Gunthorpe
2024-04-06 16:05                             ` Alexander Duyck
2024-04-06 16:49                               ` Andrew Lunn
2024-04-06 17:16                                 ` Alexander Duyck
2024-04-08 15:04                               ` Jakub Kicinski
2024-04-08 19:50                               ` Mina Almasry
2024-04-08 11:50                           ` Jiri Pirko
2024-04-08 15:46                             ` Alexander Duyck
2024-04-08 16:51                               ` Jiri Pirko
2024-04-08 17:32                                 ` John Fastabend
2024-04-09 11:01                                   ` Jiri Pirko
2024-04-09 13:11                                     ` Alexander Lobakin
2024-04-09 13:18                                       ` Jason Gunthorpe
2024-04-09 14:08                                       ` Jakub Kicinski
2024-04-09 14:27                                         ` Jakub Kicinski
2024-04-09 14:41                                       ` Jiri Pirko
2024-04-10 11:45                                         ` Alexander Lobakin
2024-04-10 12:12                                           ` Jiri Pirko
2024-04-08 21:36                                 ` Florian Fainelli
2024-04-09 10:56                                   ` Jiri Pirko
2024-04-09 13:05                                     ` Florian Fainelli
2024-04-09 14:28                                       ` Jiri Pirko
2024-04-09 17:42                                         ` Florian Fainelli
2024-04-09 18:38                                           ` Leon Romanovsky
2024-04-08 18:16                               ` Jason Gunthorpe
2024-04-09 16:53                       ` Edward Cree
2024-04-08 11:37                   ` Jiri Pirko
2024-04-04 23:50             ` Alexander Duyck
2024-04-08 11:05             ` Jiri Pirko
2024-04-08 10:54         ` Jiri Pirko
2024-04-05 14:01 ` Przemek Kitszel
2024-04-06 16:53   ` Alexander Duyck
2024-04-09 20:51 ` Jakub Kicinski
2024-04-09 21:06   ` Willem de Bruijn
2024-04-10  7:26     ` Jiri Pirko
2024-04-10 21:30       ` Jacob Keller
2024-04-10 22:19         ` Andrew Lunn
2024-04-11  0:31           ` Jacob Keller
2024-04-09 23:42   ` Andrew Lunn
2024-04-10 15:56     ` Alexander Duyck
2024-04-10 20:01       ` Andrew Lunn
2024-04-10 21:07         ` Alexander Duyck
2024-04-10 22:37           ` Andrew Lunn
2024-04-11 16:00             ` Alexander Duyck
2024-04-11 17:32               ` Andrew Lunn
2024-04-11 23:12                 ` Alexander Duyck
2024-04-11  6:39           ` Jiri Pirko
2024-04-11 16:46             ` Alexander Duyck
2024-04-10  7:42   ` Jiri Pirko
2024-04-10 12:50     ` Przemek Kitszel
2024-04-10 13:46     ` Jakub Kicinski
2024-04-10 15:12       ` Jiri Pirko
2024-04-10 17:35         ` Jakub Kicinski
2024-04-10 17:39           ` Florian Fainelli
2024-04-10 17:56             ` Jakub Kicinski
2024-04-10 18:00               ` Florian Fainelli
2024-04-10 20:03                 ` Jakub Kicinski
2024-04-10 18:01               ` Alexander Duyck
2024-04-10 18:29                 ` Florian Fainelli
2024-04-10 19:58                   ` Jakub Kicinski
2024-04-10 22:03                     ` Jacob Keller
2024-04-11  6:31                       ` Jiri Pirko
2024-04-11 16:22                         ` Jacob Keller
2024-04-11  6:34                 ` Jiri Pirko

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=c3c155131582acf447ed0a370bf4e7701c76b425.camel@gmail.com \
    --to=alexander.duyck@gmail.com \
    --cc=alexanderduyck@fb.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).