162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci=================
462306a36Sopenharmony_ciDevlink Line card
562306a36Sopenharmony_ci=================
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciBackground
862306a36Sopenharmony_ci==========
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciThe ``devlink-linecard`` mechanism is targeted for manipulation of
1162306a36Sopenharmony_ciline cards that serve as a detachable PHY modules for modular switch
1262306a36Sopenharmony_cisystem. Following operations are provided:
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci  * Get a list of supported line card types.
1562306a36Sopenharmony_ci  * Provision of a slot with specific line card type.
1662306a36Sopenharmony_ci  * Get and monitor of line card state and its change.
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ciLine card according to the type may contain one or more gearboxes
1962306a36Sopenharmony_cito mux the lanes with certain speed to multiple ports with lanes
2062306a36Sopenharmony_ciof different speed. Line card ensures N:M mapping between
2162306a36Sopenharmony_cithe switch ASIC modules and physical front panel ports.
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ciOverview
2462306a36Sopenharmony_ci========
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciEach line card devlink object is created by device driver,
2762306a36Sopenharmony_ciaccording to the physical line card slots available on the device.
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ciSimilar to splitter cable, where the device might have no way
3062306a36Sopenharmony_ciof detection of the splitter cable geometry, the device
3162306a36Sopenharmony_cimight not have a way to detect line card type. For that devices,
3262306a36Sopenharmony_ciconcept of provisioning is introduced. It allows the user to:
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci  * Provision a line card slot with certain line card type
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci    - Device driver would instruct the ASIC to prepare all
3762306a36Sopenharmony_ci      resources accordingly. The device driver would
3862306a36Sopenharmony_ci      create all instances, namely devlink port and netdevices
3962306a36Sopenharmony_ci      that reside on the line card, according to the line card type
4062306a36Sopenharmony_ci  * Manipulate of line card entities even without line card
4162306a36Sopenharmony_ci    being physically connected or powered-up
4262306a36Sopenharmony_ci  * Setup splitter cable on line card ports
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci    - As on the ordinary ports, user may provision a splitter
4562306a36Sopenharmony_ci      cable of a certain type, without the need to
4662306a36Sopenharmony_ci      be physically connected to the port
4762306a36Sopenharmony_ci  * Configure devlink ports and netdevices
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciNetdevice carrier is decided as follows:
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci  * Line card is not inserted or powered-down
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci    - The carrier is always down
5462306a36Sopenharmony_ci  * Line card is inserted and powered up
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci    - The carrier is decided as for ordinary port netdevice
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ciLine card state
5962306a36Sopenharmony_ci===============
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ciThe ``devlink-linecard`` mechanism supports the following line card states:
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci  * ``unprovisioned``: Line card is not provisioned on the slot.
6462306a36Sopenharmony_ci  * ``unprovisioning``: Line card slot is currently being unprovisioned.
6562306a36Sopenharmony_ci  * ``provisioning``: Line card slot is currently in a process of being provisioned
6662306a36Sopenharmony_ci    with a line card type.
6762306a36Sopenharmony_ci  * ``provisioning_failed``: Provisioning was not successful.
6862306a36Sopenharmony_ci  * ``provisioned``: Line card slot is provisioned with a type.
6962306a36Sopenharmony_ci  * ``active``: Line card is powered-up and active.
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ciThe following diagram provides a general overview of ``devlink-linecard``
7262306a36Sopenharmony_cistate transitions::
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci                                          +-------------------------+
7562306a36Sopenharmony_ci                                          |                         |
7662306a36Sopenharmony_ci       +---------------------------------->      unprovisioned      |
7762306a36Sopenharmony_ci       |                                  |                         |
7862306a36Sopenharmony_ci       |                                  +--------|-------^--------+
7962306a36Sopenharmony_ci       |                                           |       |
8062306a36Sopenharmony_ci       |                                           |       |
8162306a36Sopenharmony_ci       |                                  +--------v-------|--------+
8262306a36Sopenharmony_ci       |                                  |                         |
8362306a36Sopenharmony_ci       |                                  |       provisioning      |
8462306a36Sopenharmony_ci       |                                  |                         |
8562306a36Sopenharmony_ci       |                                  +------------|------------+
8662306a36Sopenharmony_ci       |                                               |
8762306a36Sopenharmony_ci       |                 +-----------------------------+
8862306a36Sopenharmony_ci       |                 |                             |
8962306a36Sopenharmony_ci       |    +------------v------------+   +------------v------------+   +-------------------------+
9062306a36Sopenharmony_ci       |    |                         |   |                         ---->                         |
9162306a36Sopenharmony_ci       +-----   provisioning_failed   |   |       provisioned       |   |         active          |
9262306a36Sopenharmony_ci       |    |                         |   |                         <----                         |
9362306a36Sopenharmony_ci       |    +------------^------------+   +------------|------------+   +-------------------------+
9462306a36Sopenharmony_ci       |                 |                             |
9562306a36Sopenharmony_ci       |                 |                             |
9662306a36Sopenharmony_ci       |                 |                +------------v------------+
9762306a36Sopenharmony_ci       |                 |                |                         |
9862306a36Sopenharmony_ci       |                 |                |     unprovisioning      |
9962306a36Sopenharmony_ci       |                 |                |                         |
10062306a36Sopenharmony_ci       |                 |                +------------|------------+
10162306a36Sopenharmony_ci       |                 |                             |
10262306a36Sopenharmony_ci       |                 +-----------------------------+
10362306a36Sopenharmony_ci       |                                               |
10462306a36Sopenharmony_ci       +-----------------------------------------------+
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ciExample usage
10862306a36Sopenharmony_ci=============
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci.. code:: shell
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci    $ devlink lc show [ DEV [ lc LC_INDEX ] ]
11362306a36Sopenharmony_ci    $ devlink lc set DEV lc LC_INDEX [ { type LC_TYPE | notype } ]
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci    # Show current line card configuration and status for all slots:
11662306a36Sopenharmony_ci    $ devlink lc
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci    # Set slot 8 to be provisioned with type "16x100G":
11962306a36Sopenharmony_ci    $ devlink lc set pci/0000:01:00.0 lc 8 type 16x100G
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci    # Set slot 8 to be unprovisioned:
12262306a36Sopenharmony_ci    $ devlink lc set pci/0000:01:00.0 lc 8 notype
123