[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221027130049.2418531-4-michal.wilczynski@intel.com>
Date: Thu, 27 Oct 2022 15:00:43 +0200
From: Michal Wilczynski <michal.wilczynski@...el.com>
To: netdev@...r.kernel.org
Cc: alexandr.lobakin@...el.com, jacob.e.keller@...el.com,
jesse.brandeburg@...el.com, przemyslaw.kitszel@...el.com,
anthony.l.nguyen@...el.com, kuba@...nel.org,
ecree.xilinx@...il.com, jiri@...nulli.us,
Michal Wilczynski <michal.wilczynski@...el.com>
Subject: [PATCH net-next v7 3/9] devlink: Enable creation of the devlink-rate nodes from the driver
Intel 100G card internal firmware hierarchy for Hierarchicial QoS is very
rigid and can't be easily removed. This requires an ability to export
default hierarchy to allow user to modify it. Currently the driver is
only able to create the 'leaf' nodes, which usually represent the vport.
This is not enough for HQoS implemented in Intel hardware.
Introduce new function devl_rate_node_create() that allows for creation
of the devlink-rate nodes from the driver.
Signed-off-by: Michal Wilczynski <michal.wilczynski@...el.com>
---
include/net/devlink.h | 4 ++++
net/core/devlink.c | 47 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+)
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 929cb72ef412..facc4cee5d6b 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -98,6 +98,8 @@ struct devlink_port_attrs {
};
};
+#define DEVLINK_RATE_NAME_MAX_LEN 30
+
struct devlink_rate {
struct list_head list;
enum devlink_rate_type type;
@@ -1601,6 +1603,8 @@ void devlink_port_attrs_pci_sf_set(struct devlink_port *devlink_port,
u32 controller, u16 pf, u32 sf,
bool external);
int devl_rate_leaf_create(struct devlink_port *port, void *priv);
+int devl_rate_node_create(struct devlink *devlink, void *priv, char *node_name,
+ char *parent_name);
void devl_rate_leaf_destroy(struct devlink_port *devlink_port);
void devl_rate_nodes_destroy(struct devlink *devlink);
void devlink_port_linecard_set(struct devlink_port *devlink_port,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index b97c077cf66e..864fa0967b7a 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -10270,6 +10270,53 @@ void devlink_port_attrs_pci_sf_set(struct devlink_port *devlink_port, u32 contro
}
EXPORT_SYMBOL_GPL(devlink_port_attrs_pci_sf_set);
+/**
+ * devl_rate_node_create - create devlink rate node
+ * @devlink: devlink instance
+ * @priv: driver private data
+ * @node_name: name of the resulting node
+ * @parent_name: name of the parent node
+ *
+ * Create devlink rate object of type node
+ */
+int devl_rate_node_create(struct devlink *devlink, void *priv, char *node_name, char *parent_name)
+{
+ struct devlink_rate *rate_node;
+ struct devlink_rate *parent;
+
+ rate_node = devlink_rate_node_get_by_name(devlink, node_name);
+ if (!IS_ERR(rate_node))
+ return -EEXIST;
+
+ rate_node = kzalloc(sizeof(*rate_node), GFP_KERNEL);
+ if (!rate_node)
+ return -ENOMEM;
+
+ if (parent_name) {
+ parent = devlink_rate_node_get_by_name(devlink, parent_name);
+ if (IS_ERR(parent))
+ return -ENODEV;
+ rate_node->parent = parent;
+ refcount_inc(&rate_node->parent->refcnt);
+ }
+
+ rate_node->type = DEVLINK_RATE_TYPE_NODE;
+ rate_node->devlink = devlink;
+ rate_node->priv = priv;
+
+ rate_node->name = kzalloc(DEVLINK_RATE_NAME_MAX_LEN, GFP_KERNEL);
+ if (!rate_node->name)
+ return -ENOMEM;
+
+ strscpy(rate_node->name, node_name, DEVLINK_RATE_NAME_MAX_LEN);
+
+ refcount_set(&rate_node->refcnt, 1);
+ list_add(&rate_node->list, &devlink->rate_list);
+ devlink_rate_notify(rate_node, DEVLINK_CMD_RATE_NEW);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(devl_rate_node_create);
+
/**
* devl_rate_leaf_create - create devlink rate leaf
* @devlink_port: devlink port object to create rate object on
--
2.37.2
Powered by blists - more mailing lists