DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: dev@dpdk.org
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	Bruce Richardson <bruce.richardson@intel.com>,
	Anatoly Burakov <anatoly.burakov@intel.com>
Subject: [dpdk-dev] [PATCH v10 10/20] unci: init netlink
Date: Tue,  4 Jul 2017 17:13:27 +0100	[thread overview]
Message-ID: <20170704161337.45926-11-ferruh.yigit@intel.com> (raw)
In-Reply-To: <20170704161337.45926-1-ferruh.yigit@intel.com>

Initialize netlink socket.

Userspace application will connect to the socket for data transfer.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 .../linuxapp/eal/include/exec-env/unci.h           | 33 ++++++++++
 lib/librte_eal/linuxapp/unci/Makefile              |  1 +
 lib/librte_eal/linuxapp/unci/unci_dev.h            |  3 +
 lib/librte_eal/linuxapp/unci/unci_net.c            |  7 +++
 lib/librte_eal/linuxapp/unci/unci_nl.c             | 72 ++++++++++++++++++++++
 5 files changed, 116 insertions(+)
 create mode 100644 lib/librte_eal/linuxapp/unci/unci_nl.c

diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/unci.h b/lib/librte_eal/linuxapp/eal/include/exec-env/unci.h
index 8d4a95777..6d3490aee 100644
--- a/lib/librte_eal/linuxapp/eal/include/exec-env/unci.h
+++ b/lib/librte_eal/linuxapp/eal/include/exec-env/unci.h
@@ -60,6 +60,20 @@
 
 #define UNCI_DEVICE "unci"
 
+#define UNCI_GENL_MSG_LEN 1536
+
+#define UNCI_NL_MSG_LEN 500
+struct unci_nl_msg {
+	__u32 cmd_id;
+	__u32 port_id;
+	__u32 flag;
+	__u8 input_buffer[UNCI_NL_MSG_LEN];
+	__u8 output_buffer[UNCI_NL_MSG_LEN];
+	size_t input_buffer_len;
+	size_t output_buffer_len;
+	int err;
+};
+
 /* can go into include/uapi/linux/if_link.h */
 enum {
 	IFLA_UNCI_UNSPEC,
@@ -70,4 +84,23 @@ enum {
 
 #define IFLA_UNCI_MAX (__IFLA_UNCI_MAX - 1)
 
+
+#define UNCI_GENL_VERSION 1
+
+enum {
+	UNCI_ATTR_UNSPEC,
+	UNCI_ATTR_MSG,
+	__UNCI_ATTR_MAX,
+};
+
+#define UNCI_ATTR_MAX (__UNCI_ATTR_MAX - 1)
+
+enum {
+	UNCI_CMD_UNSPEC,
+	UNCI_CMD_MSG,
+	__UNCI_CMD_MAX,
+};
+
+#define UNCI_CMD_MAX (__UNCI_CMD_MAX - 1)
+
 #endif /* _UAPI_LINUX_UNCI_H_ */
diff --git a/lib/librte_eal/linuxapp/unci/Makefile b/lib/librte_eal/linuxapp/unci/Makefile
index 02e354814..c2a81be7d 100644
--- a/lib/librte_eal/linuxapp/unci/Makefile
+++ b/lib/librte_eal/linuxapp/unci/Makefile
@@ -48,5 +48,6 @@ MODULE_CFLAGS += -Wall -Werror
 # all source are stored in SRCS-y
 #
 SRCS-$(CONFIG_RTE_UNCI_KMOD) := unci_net.c
+SRCS-$(CONFIG_RTE_UNCI_KMOD) += unci_nl.c
 
 include $(RTE_SDK)/mk/rte.module.mk
diff --git a/lib/librte_eal/linuxapp/unci/unci_dev.h b/lib/librte_eal/linuxapp/unci/unci_dev.h
index 92b9b8383..a748abf98 100644
--- a/lib/librte_eal/linuxapp/unci/unci_dev.h
+++ b/lib/librte_eal/linuxapp/unci/unci_dev.h
@@ -39,4 +39,7 @@ struct unci_dev {
 	__u32 pid;
 };
 
+int unci_nl_init(void);
+void unci_nl_release(void);
+
 #endif /* _UNCI_DEV_H_ */
diff --git a/lib/librte_eal/linuxapp/unci/unci_net.c b/lib/librte_eal/linuxapp/unci/unci_net.c
index 42fac3e63..1989b6d23 100644
--- a/lib/librte_eal/linuxapp/unci/unci_net.c
+++ b/lib/librte_eal/linuxapp/unci/unci_net.c
@@ -74,6 +74,12 @@ static struct rtnl_link_ops unci_link_ops __read_mostly = {
 
 static int __init unci_init(void)
 {
+	int ret;
+
+	ret = unci_nl_init();
+	if (ret)
+		return ret;
+
 	return rtnl_link_register(&unci_link_ops);
 }
 module_init(unci_init);
@@ -81,6 +87,7 @@ module_init(unci_init);
 static void __exit unci_exit(void)
 {
 	rtnl_link_unregister(&unci_link_ops);
+	unci_nl_release();
 }
 module_exit(unci_exit);
 
diff --git a/lib/librte_eal/linuxapp/unci/unci_nl.c b/lib/librte_eal/linuxapp/unci/unci_nl.c
new file mode 100644
index 000000000..1461a3309
--- /dev/null
+++ b/lib/librte_eal/linuxapp/unci/unci_nl.c
@@ -0,0 +1,72 @@
+/*-
+ * GPL LICENSE SUMMARY
+ *
+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of version 2 of the GNU General Public License as
+ *   published by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful, but
+ *   WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *   General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program;
+ *   The full GNU General Public License is included in this distribution
+ *   in the file called LICENSE.GPL.
+ *
+ *   Contact Information:
+ *   Intel Corporation
+ */
+
+#include <net/genetlink.h>
+#include <net/sock.h>
+
+#include "unci_dev.h"
+
+static int unci_genl_process(struct sk_buff *skb, struct genl_info *info)
+{
+	struct nlattr **attrs = info->attrs;
+	struct unci_nl_msg nl_msg;
+
+	if (!attrs[UNCI_ATTR_MSG])
+		return -EINVAL;
+
+	nla_memcpy(&nl_msg, attrs[UNCI_ATTR_MSG], sizeof(struct unci_nl_msg));
+	pr_debug("cmd: %u\n", nl_msg.cmd_id);
+
+	return 0;
+}
+
+static struct nla_policy unci_genl_policy[UNCI_ATTR_MAX + 1] = {
+	[UNCI_ATTR_MSG] = { .type = NLA_BINARY, .len = UNCI_GENL_MSG_LEN },
+};
+
+static const struct genl_ops unci_ops[] = {
+	{
+		.cmd = UNCI_CMD_MSG,
+		.doit = unci_genl_process,
+		.policy = unci_genl_policy,
+	},
+};
+
+static struct genl_family unci_genl_family __ro_after_init = {
+	.module = THIS_MODULE,
+	.name = UNCI_DEVICE,
+	.version = UNCI_GENL_VERSION,
+	.maxattr = UNCI_ATTR_MAX,
+	.ops = unci_ops,
+	.n_ops = ARRAY_SIZE(unci_ops),
+};
+
+int unci_nl_init(void)
+{
+	return genl_register_family(&unci_genl_family);
+}
+
+void unci_nl_release(void)
+{
+	genl_unregister_family(&unci_genl_family);
+}
-- 
2.13.0

  parent reply	other threads:[~2017-07-04 16:14 UTC|newest]

Thread overview: 91+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26 16:52 [dpdk-dev] [RFC] Kernel Control Path (KCP) Ferruh Yigit
2017-05-28 16:55 ` Wiles, Keith
2017-05-29  9:26   ` Bruce Richardson
2017-05-29 17:29     ` Wiles, Keith
2017-06-16 15:54   ` Ferruh Yigit
2017-06-20 12:33     ` Ferruh Yigit
2017-05-30 10:55 ` Thomas Monjalon
2017-06-13 17:21   ` Ferruh Yigit
2017-06-13 18:00     ` Jay Rolette
2017-06-13 18:04       ` Dumitrescu, Cristian
2017-06-13 18:18         ` Wiles, Keith
2017-06-15 12:07           ` Alex Rosenbaum
2017-06-16 15:27             ` Ferruh Yigit
2017-06-16 16:48               ` Stephen Hemminger
2017-06-13 18:17       ` Wiles, Keith
2017-06-21 11:06 ` [dpdk-dev] [PATCH v8 0/4] Userspace Network Control Interface (UNCI) Ferruh Yigit
2017-06-21 11:06   ` [dpdk-dev] [PATCH v8 1/4] ethtool: move from sample folder to lib folder Ferruh Yigit
2017-06-26 11:02     ` Bruce Richardson
2017-06-21 11:06   ` [dpdk-dev] [PATCH v8 2/4] unci: add kernel control path kernel module Ferruh Yigit
2017-06-21 15:23     ` Stephen Hemminger
2017-06-30 17:02       ` Ferruh Yigit
2017-06-21 11:06   ` [dpdk-dev] [PATCH v8 3/4] rte_ctrl_if: add control interface library Ferruh Yigit
2017-06-26 11:09     ` Bruce Richardson
2017-06-26 11:30     ` Bruce Richardson
2017-06-21 11:06   ` [dpdk-dev] [PATCH v8 4/4] ethdev: add control interface support Ferruh Yigit
2017-06-21 15:24     ` Stephen Hemminger
2017-06-30 17:06       ` Ferruh Yigit
2017-06-26 11:39   ` [dpdk-dev] [PATCH v8 0/4] Userspace Network Control Interface (UNCI) Bruce Richardson
2017-06-29 16:13     ` Ferruh Yigit
2017-06-30 16:56       ` Ferruh Yigit
2017-06-30 16:51   ` [dpdk-dev] [PATCH v9 00/20] " Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 01/20] ethtool: add library skeleton Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 02/20] ethtool: move from sample folder into lib folder Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 03/20] ethtool: remove PMD specific API call Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 04/20] ethtool: update header doxygen syntax Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 05/20] ethtool: enable library Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 06/20] doc: add ethtool library documentation Ferruh Yigit
2017-07-02 20:18       ` Mcnamara, John
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 07/20] doc: update ethtool sample app doc Ferruh Yigit
2017-07-02 20:17       ` Mcnamara, John
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 08/20] unci: add module skeleton Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 09/20] unci: add rtnl newlink Ferruh Yigit
2017-06-30 17:27       ` Stephen Hemminger
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 10/20] unci: init netlink Ferruh Yigit
2017-06-30 17:28       ` Stephen Hemminger
2017-06-30 17:29       ` Stephen Hemminger
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 11/20] unci: add netlink exec Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 12/20] unci: add netdevice ops Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 13/20] unci: add ethtool support Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 14/20] ctrl_if: add library skeleton Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 15/20] ctrl_if: add create destroy interface APIs Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 16/20] ctrl_if: initialize netlink interface Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 17/20] ctrl_if: process control messages Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 18/20] ctrl_if: process ethtool messages Ferruh Yigit
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 19/20] doc: add control interface library documentation Ferruh Yigit
2017-07-02 20:16       ` Mcnamara, John
2017-06-30 16:51     ` [dpdk-dev] [PATCH v9 20/20] ethdev: add control interface support Ferruh Yigit
2017-07-04 16:13     ` [dpdk-dev] [PATCH v10 00/20] Userspace Network Control Interface (UNCI) Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 01/20] ethtool: add library skeleton Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 02/20] ethtool: move from sample folder into lib folder Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 03/20] ethtool: remove PMD specific API call Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 04/20] ethtool: update header doxygen syntax Ferruh Yigit
2017-07-06  9:18         ` Burakov, Anatoly
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 05/20] ethtool: enable library Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 06/20] doc: add ethtool library documentation Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 07/20] doc: update ethtool sample app doc Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 08/20] unci: add module skeleton Ferruh Yigit
2017-07-06  9:25         ` Burakov, Anatoly
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 09/20] unci: add rtnl newlink Ferruh Yigit
2017-07-04 16:13       ` Ferruh Yigit [this message]
2017-07-06  9:32         ` [dpdk-dev] [PATCH v10 10/20] unci: init netlink Burakov, Anatoly
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 11/20] unci: add netlink exec Ferruh Yigit
2017-07-05 19:07         ` Stephen Hemminger
2017-07-06 10:45           ` Ferruh Yigit
2017-07-07  0:25             ` Stephen Hemminger
2017-07-05 19:15         ` Stephen Hemminger
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 12/20] unci: add netdevice ops Ferruh Yigit
2017-07-05 19:12         ` Stephen Hemminger
2017-07-05 19:12         ` Stephen Hemminger
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 13/20] unci: add ethtool support Ferruh Yigit
2017-07-05 19:07         ` Stephen Hemminger
2017-07-05 19:08         ` Stephen Hemminger
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 14/20] ctrl_if: add library skeleton Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 15/20] ctrl_if: add create destroy interface APIs Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 16/20] ctrl_if: initialize generic netlink interface Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 17/20] ctrl_if: process control messages Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 18/20] ctrl_if: process ethtool messages Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 19/20] doc: add control interface library documentation Ferruh Yigit
2017-07-04 16:13       ` [dpdk-dev] [PATCH v10 20/20] ethdev: add control interface support Ferruh Yigit
2017-07-08  6:28         ` Yuanhan Liu
2017-07-20 14:55           ` Ferruh Yigit

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=20170704161337.45926-11-ferruh.yigit@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /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).