Re: [ovs-dev] [PATCH] lib: Introduce netlink-devlink library

2021-05-05 Thread 0-day Robot
Bleep bloop.  Greetings Frode Nordahl, I am a robot and I have tried out your 
patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
ERROR: Inappropriate spacing in pointer declaration
WARNING: Line lacks whitespace around operator
#874 FILE: lib/netlink-devlink.c:139:
(bool (*)(struct ofpbuf*, void*))_dl_parse_port_policy,

ERROR: Inappropriate spacing in pointer declaration
ERROR: Inappropriate spacing around cast
WARNING: Line lacks whitespace around operator
#875 FILE: lib/netlink-devlink.c:140:
(void*)port_entry);

ERROR: Inappropriate spacing in pointer declaration
WARNING: Line lacks whitespace around operator
#884 FILE: lib/netlink-devlink.c:149:
(bool (*)(struct ofpbuf*, void*))_dl_parse_info_policy,

ERROR: Inappropriate spacing in pointer declaration
ERROR: Inappropriate spacing around cast
WARNING: Line lacks whitespace around operator
#885 FILE: lib/netlink-devlink.c:150:
(void*)info_entry);

ERROR: Improper whitespace around control block
#901 FILE: lib/netlink-devlink.c:166:
switch(policy[attr_idx].type) {

ERROR: Inappropriate bracing around statement
#1068 FILE: lib/netlink-devlink.c:333:
else

WARNING: Line lacks whitespace around operator
#1206 FILE: lib/netlink-devlink.c:471:
||!attr_fill_version(DEVLINK_ATTR_INFO_VERSION_RUNNING, attrs,

WARNING: Line lacks whitespace around operator
#1208 FILE: lib/netlink-devlink.c:473:
||!attr_fill_version(DEVLINK_ATTR_INFO_VERSION_STORED, attrs,

WARNING: Line is 95 characters long (recommended limit is 79)
#1710 FILE: utilities/devlink.c:81:
VLOG_INFO("function eth_addr: "ETH_ADDR_FMT, 
ETH_ADDR_ARGS(port_entry->function.eth_addr));

ERROR: Improper whitespace around control block
#1826 FILE: utilities/devlink.c:197:
if(!nl_dl_parse_port_policy(, _entry)) {

WARNING: Line is 80 characters long (recommended limit is 79)
#1831 FILE: utilities/devlink.c:202:
genl->cmd == DEVLINK_CMD_PORT_GET ? "DEVLINK_CMD_PORT_GET" :

WARNING: Line is 80 characters long (recommended limit is 79)
#1832 FILE: utilities/devlink.c:203:
genl->cmd == DEVLINK_CMD_PORT_SET ? "DEVLINK_CMD_PORT_SET" :

WARNING: Line is 80 characters long (recommended limit is 79)
#1833 FILE: utilities/devlink.c:204:
genl->cmd == DEVLINK_CMD_PORT_NEW ? "DEVLINK_CMD_PORT_NEW" :

WARNING: Line is 80 characters long (recommended limit is 79)
#1834 FILE: utilities/devlink.c:205:
genl->cmd == DEVLINK_CMD_PORT_DEL ? "DEVLINK_CMD_PORT_DEL" :

Lines checked: 1877, Warnings: 11, Errors: 9


Please check this out.  If you feel there has been an error, please email 
acon...@redhat.com

Thanks,
0-day Robot
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH] lib: Introduce netlink-devlink library

2021-05-05 Thread Frode Nordahl
The devlink interface was introduced [0] in the Linux 4.6 time
frame and has since gained traction among multiple hardware
vendors.

The devlink-port [1] and devlink-info[2] interfaces are
particularly useful for managing NICs connected to multiple
distinct CPUs such as SmartNICs.

In such a topology it would be useful to be able to offload
Open vSwitch and OVN onto the NIC SoC operating system and this
library will help with discovering and managing ports representing
resources made available on the host from the NIC SoC side.

The library will be consumed by upcoming proposed changes to OVN,
and I think it makes sense to maintain it together with the Open
vSwitch netlink library code. The proposed changes are also
referenced in specifications proposed to the OpenStack project [3][4].

0: 
https://lore.kernel.org/netdev/1456504351-18871-1-git-send-email-j...@resnulli.us/
1: 
https://github.com/torvalds/linux/blob/master/Documentation/networking/devlink/devlink-port.rst
2: 
https://github.com/torvalds/linux/blob/master/Documentation/networking/devlink/devlink-info.rst
3: https://review.opendev.org/c/openstack/nova-specs/+/787458
4: https://review.opendev.org/c/openstack/neutron-specs/+/788821
Signed-off-by: Frode Nordahl 
---
 include/linux/automake.mk |   1 +
 include/linux/devlink.h   | 625 ++
 include/openvswitch/types.h   |   8 +
 lib/automake.mk   |   2 +
 lib/netlink-devlink.c | 498 
 lib/netlink-devlink.h | 114 ++
 lib/netlink.c |  16 +
 lib/netlink.h |   5 +
 lib/packets.h |   1 +
 tests/.gitignore  |   3 +
 tests/automake.mk |  16 +
 tests/system-devlink-info.at  |   9 +
 tests/system-devlink-port.at  |  12 +
 tests/system-devlink-testsuite.at |  45 +++
 utilities/.gitignore  |   1 +
 utilities/automake.mk |   3 +
 utilities/devlink.c   | 245 
 17 files changed, 1604 insertions(+)
 create mode 100644 include/linux/devlink.h
 create mode 100644 lib/netlink-devlink.c
 create mode 100644 lib/netlink-devlink.h
 create mode 100644 tests/system-devlink-info.at
 create mode 100644 tests/system-devlink-port.at
 create mode 100644 tests/system-devlink-testsuite.at
 create mode 100644 utilities/devlink.c

diff --git a/include/linux/automake.mk b/include/linux/automake.mk
index 8f063f482..8718f980d 100644
--- a/include/linux/automake.mk
+++ b/include/linux/automake.mk
@@ -1,4 +1,5 @@
 noinst_HEADERS += \
+   include/linux/devlink.h \
include/linux/netlink.h \
include/linux/netfilter/nf_conntrack_sctp.h \
include/linux/pkt_cls.h \
diff --git a/include/linux/devlink.h b/include/linux/devlink.h
new file mode 100644
index 0..28ea92b62
--- /dev/null
+++ b/include/linux/devlink.h
@@ -0,0 +1,625 @@
+/*
+ * The kernel devlink interface has gained a number of additions in recent
+ * kernel versions. To allow Open vSwitch to consume these interfaces in its
+ * runtime environment regardless of what kernel version was available at build
+ * time, and also avoiding an elaborate set of autoconf macros to check for
+ * presence of individual pieces, we include the entire file here.
+ *
+ * Source:
+ * 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/include/uapi/linux/devlink.h
 @ a556dded9c23c51c82654f1ebe389cbc0bc22057 */
+#if !defined(__KERNEL__)
+#ifndef __UAPI_LINUX_DEVLINK_WRAPPER_H
+#define __UAPI_LINUX_DEVLINK_WRAPPER_H 1
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
+/*
+ * include/uapi/linux/devlink.h - Network physical device Netlink interface
+ * Copyright (c) 2016 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2016 Jiri Pirko 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _UAPI_LINUX_DEVLINK_H_
+#define _UAPI_LINUX_DEVLINK_H_
+
+#include 
+
+#define DEVLINK_GENL_NAME "devlink"
+#define DEVLINK_GENL_VERSION 0x1
+#define DEVLINK_GENL_MCGRP_CONFIG_NAME "config"
+
+enum devlink_command {
+   /* don't change the order or add anything between, this is ABI! */
+   DEVLINK_CMD_UNSPEC,
+
+   DEVLINK_CMD_GET,/* can dump */
+   DEVLINK_CMD_SET,
+   DEVLINK_CMD_NEW,
+   DEVLINK_CMD_DEL,
+
+   DEVLINK_CMD_PORT_GET,   /* can dump */
+   DEVLINK_CMD_PORT_SET,
+   DEVLINK_CMD_PORT_NEW,
+   DEVLINK_CMD_PORT_DEL,
+
+   DEVLINK_CMD_PORT_SPLIT,
+   DEVLINK_CMD_PORT_UNSPLIT,
+
+   DEVLINK_CMD_SB_GET, /* can dump */
+   DEVLINK_CMD_SB_SET,
+   DEVLINK_CMD_SB_NEW,
+   DEVLINK_CMD_SB_DEL,
+
+   DEVLINK_CMD_SB_POOL_GET,/* can dump */
+