Commit fcdc8ce2 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

devlink: implement line card provisioning

In order to be able to configure all needed stuff on a port/netdevice
of a line card without the line card being present, introduce line card
provisioning. Basically by setting a type, provisioning process will
start and driver is supposed to create a placeholder for instances
(ports/netdevices) for a line card type.

Allow the user to query the supported line card types over line card
get command. Then implement two netlink command SET to allow user to
set/unset the card type.

On the driver API side, add provision/unprovision ops and supported
types array to be advertised. Upon provision op call, the driver should
take care of creating the instances for the particular line card type.
Introduce provision_set/clear() functions to be called by the driver
once the provisioning/unprovisioning is done on its side. These helpers
are not to be called directly due to the async nature of provisioning.

Example:
$ devlink port # No ports are listed
$ devlink lc
pci/0000:01:00.0:
  lc 1 state unprovisioned
    supported_types:
       16x100G
  lc 2 state unprovisioned
    supported_types:
       16x100G
  lc 3 state unprovisioned
    supported_types:
       16x100G
  lc 4 state unprovisioned
    supported_types:
       16x100G
  lc 5 state unprovisioned
    supported_types:
       16x100G
  lc 6 state unprovisioned
    supported_types:
       16x100G
  lc 7 state unprovisioned
    supported_types:
       16x100G
  lc 8 state unprovisioned
    supported_types:
       16x100G

$ devlink lc set pci/0000:01:00.0 lc 8 type 16x100G
$ devlink lc show pci/0000:01:00.0 lc 8
pci/0000:01:00.0:
  lc 8 state active type 16x100G
    supported_types:
       16x100G
$ devlink port
pci/0000:01:00.0/0: type notset flavour cpu port 0 splittable false
pci/0000:01:00.0/53: type eth netdev enp1s0nl8p1 flavour physical lc 8 port 1 splittable true lanes 4
pci/0000:01:00.0/54: type eth netdev enp1s0nl8p2 flavour physical lc 8 port 2 splittable true lanes 4
pci/0000:01:00.0/55: type eth netdev enp1s0nl8p3 flavour physical lc 8 port 3 splittable true lanes 4
pci/0000:01:00.0/56: type eth netdev enp1s0nl8p4 flavour physical lc 8 port 4 splittable true lanes 4
pci/0000:01:00.0/57: type eth netdev enp1s0nl8p5 flavour physical lc 8 port 5 splittable true lanes 4
pci/0000:01:00.0/58: type eth netdev enp1s0nl8p6 flavour physical lc 8 port 6 splittable true lanes 4
pci/0000:01:00.0/59: type eth netdev enp1s0nl8p7 flavour physical lc 8 port 7 splittable true lanes 4
pci/0000:01:00.0/60: type eth netdev enp1s0nl8p8 flavour physical lc 8 port 8 splittable true lanes 4
pci/0000:01:00.0/61: type eth netdev enp1s0nl8p9 flavour physical lc 8 port 9 splittable true lanes 4
pci/0000:01:00.0/62: type eth netdev enp1s0nl8p10 flavour physical lc 8 port 10 splittable true lanes 4
pci/0000:01:00.0/63: type eth netdev enp1s0nl8p11 flavour physical lc 8 port 11 splittable true lanes 4
pci/0000:01:00.0/64: type eth netdev enp1s0nl8p12 flavour physical lc 8 port 12 splittable true lanes 4
pci/0000:01:00.0/125: type eth netdev enp1s0nl8p13 flavour physical lc 8 port 13 splittable true lanes 4
pci/0000:01:00.0/126: type eth netdev enp1s0nl8p14 flavour physical lc 8 port 14 splittable true lanes 4
pci/0000:01:00.0/127: type eth netdev enp1s0nl8p15 flavour physical lc 8 port 15 splittable true lanes 4
pci/0000:01:00.0/128: type eth netdev enp1s0nl8p16 flavour physical lc 8 port 16 splittable true lanes 4

$ devlink lc set pci/0000:01:00.0 lc 8 notype
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c246f9b5
.. SPDX-License-Identifier: GPL-2.0
=================
Devlink Line card
=================
Background
==========
The ``devlink-linecard`` mechanism is targeted for manipulation of
line cards that serve as a detachable PHY modules for modular switch
system. Following operations are provided:
* Get a list of supported line card types.
* Provision of a slot with specific line card type.
* Get and monitor of line card state and its change.
Line card according to the type may contain one or more gearboxes
to mux the lanes with certain speed to multiple ports with lanes
of different speed. Line card ensures N:M mapping between
the switch ASIC modules and physical front panel ports.
Overview
========
Each line card devlink object is created by device driver,
according to the physical line card slots available on the device.
Similar to splitter cable, where the device might have no way
of detection of the splitter cable geometry, the device
might not have a way to detect line card type. For that devices,
concept of provisioning is introduced. It allows the user to:
* Provision a line card slot with certain line card type
- Device driver would instruct the ASIC to prepare all
resources accordingly. The device driver would
create all instances, namely devlink port and netdevices
that reside on the line card, according to the line card type
* Manipulate of line card entities even without line card
being physically connected or powered-up
* Setup splitter cable on line card ports
- As on the ordinary ports, user may provision a splitter
cable of a certain type, without the need to
be physically connected to the port
* Configure devlink ports and netdevices
Netdevice carrier is decided as follows:
* Line card is not inserted or powered-down
- The carrier is always down
* Line card is inserted and powered up
- The carrier is decided as for ordinary port netdevice
Line card state
===============
The ``devlink-linecard`` mechanism supports the following line card states:
* ``unprovisioned``: Line card is not provisioned on the slot.
* ``unprovisioning``: Line card slot is currently being unprovisioned.
* ``provisioning``: Line card slot is currently in a process of being provisioned
with a line card type.
* ``provisioning_failed``: Provisioning was not successful.
* ``provisioned``: Line card slot is provisioned with a type.
The following diagram provides a general overview of ``devlink-linecard``
state transitions::
+-------------------------+
| |
+----------------------------------> unprovisioned |
| | |
| +--------|-------^--------+
| | |
| | |
| +--------v-------|--------+
| | |
| | provisioning |
| | |
| +------------|------------+
| |
| +-----------------------------+
| | |
| +------------v------------+ +------------v------------+
| | | | |
+----- provisioning_failed | | provisioned |
| | | | |
| +------------^------------+ +------------|------------+
| | |
| | |
| | +------------v------------+
| | | |
| | | unprovisioning |
| | | |
| | +------------|------------+
| | |
| +-----------------------------+
| |
+-----------------------------------------------+
Example usage
=============
.. code:: shell
$ devlink lc show [ DEV [ lc LC_INDEX ] ]
$ devlink lc set DEV lc LC_INDEX [ { type LC_TYPE | notype } ]
# Show current line card configuration and status for all slots:
$ devlink lc
# Set slot 8 to be provisioned with type "16x100G":
$ devlink lc set pci/0000:01:00.0 lc 8 type 16x100G
# Set slot 8 to be unprovisioned:
$ devlink lc set pci/0000:01:00.0 lc 8 notype
......@@ -39,6 +39,7 @@ general.
devlink-resource
devlink-reload
devlink-trap
devlink-linecard
Driver-specific documentation
-----------------------------
......
......@@ -149,6 +149,40 @@ struct devlink_port_new_attrs {
sfnum_valid:1;
};
/**
* struct devlink_linecard_ops - Linecard operations
* @provision: callback to provision the linecard slot with certain
* type of linecard. As a result of this operation,
* driver is expected to eventually (could be after
* the function call returns) call one of:
* devlink_linecard_provision_set()
* devlink_linecard_provision_fail()
* @unprovision: callback to unprovision the linecard slot. As a result
* of this operation, driver is expected to eventually
* (could be after the function call returns) call
* devlink_linecard_provision_clear()
* devlink_linecard_provision_fail()
* @same_provision: callback to ask the driver if linecard is already
* provisioned in the same way user asks this linecard to be
* provisioned.
* @types_count: callback to get number of supported types
* @types_get: callback to get next type in list
*/
struct devlink_linecard_ops {
int (*provision)(struct devlink_linecard *linecard, void *priv,
const char *type, const void *type_priv,
struct netlink_ext_ack *extack);
int (*unprovision)(struct devlink_linecard *linecard, void *priv,
struct netlink_ext_ack *extack);
bool (*same_provision)(struct devlink_linecard *linecard, void *priv,
const char *type, const void *type_priv);
unsigned int (*types_count)(struct devlink_linecard *linecard,
void *priv);
void (*types_get)(struct devlink_linecard *linecard,
void *priv, unsigned int index, const char **type,
const void **type_priv);
};
struct devlink_sb_pool_info {
enum devlink_sb_pool_type pool_type;
u32 size;
......@@ -1537,9 +1571,14 @@ void devlink_port_attrs_pci_sf_set(struct devlink_port *devlink_port,
int devlink_rate_leaf_create(struct devlink_port *port, void *priv);
void devlink_rate_leaf_destroy(struct devlink_port *devlink_port);
void devlink_rate_nodes_destroy(struct devlink *devlink);
struct devlink_linecard *devlink_linecard_create(struct devlink *devlink,
unsigned int linecard_index);
struct devlink_linecard *
devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index,
const struct devlink_linecard_ops *ops, void *priv);
void devlink_linecard_destroy(struct devlink_linecard *linecard);
void devlink_linecard_provision_set(struct devlink_linecard *linecard,
const char *type);
void devlink_linecard_provision_clear(struct devlink_linecard *linecard);
void devlink_linecard_provision_fail(struct devlink_linecard *linecard);
int devlink_sb_register(struct devlink *devlink, unsigned int sb_index,
u32 size, u16 ingress_pools_count,
u16 egress_pools_count, u16 ingress_tc_count,
......
......@@ -343,6 +343,18 @@ enum devlink_reload_limit {
#define DEVLINK_RELOAD_LIMITS_VALID_MASK (_BITUL(__DEVLINK_RELOAD_LIMIT_MAX) - 1)
enum devlink_linecard_state {
DEVLINK_LINECARD_STATE_UNSPEC,
DEVLINK_LINECARD_STATE_UNPROVISIONED,
DEVLINK_LINECARD_STATE_UNPROVISIONING,
DEVLINK_LINECARD_STATE_PROVISIONING,
DEVLINK_LINECARD_STATE_PROVISIONING_FAILED,
DEVLINK_LINECARD_STATE_PROVISIONED,
__DEVLINK_LINECARD_STATE_MAX,
DEVLINK_LINECARD_STATE_MAX = __DEVLINK_LINECARD_STATE_MAX - 1
};
enum devlink_attr {
/* don't change the order or add anything between, this is ABI! */
DEVLINK_ATTR_UNSPEC,
......@@ -559,6 +571,9 @@ enum devlink_attr {
DEVLINK_ATTR_REGION_MAX_SNAPSHOTS, /* u32 */
DEVLINK_ATTR_LINECARD_INDEX, /* u32 */
DEVLINK_ATTR_LINECARD_STATE, /* u8 */
DEVLINK_ATTR_LINECARD_TYPE, /* string */
DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES, /* nested */
/* add new attributes above here, update the policy in devlink.c */
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment