From patchwork Fri Jun 30 16:51:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 26122 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id A5C817CC3; Fri, 30 Jun 2017 18:52:30 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 7022958CE for ; Fri, 30 Jun 2017 18:52:04 +0200 (CEST) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jun 2017 09:51:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,287,1496127600"; d="scan'208";a="103233223" Received: from silpixa00372839.ir.intel.com (HELO silpixa00372839.ger.corp.intel.com) ([10.237.222.154]) by orsmga004.jf.intel.com with ESMTP; 30 Jun 2017 09:51:57 -0700 From: Ferruh Yigit To: dev@dpdk.org Cc: Ferruh Yigit , Stephen Hemminger , Bruce Richardson , Anatoly Burakov Date: Fri, 30 Jun 2017 17:51:30 +0100 Message-Id: <20170630165140.59594-11-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170630165140.59594-1-ferruh.yigit@intel.com> References: <20170621110651.75299-1-ferruh.yigit@intel.com> <20170630165140.59594-1-ferruh.yigit@intel.com> Subject: [dpdk-dev] [PATCH v9 10/20] unci: init netlink X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Initialize netlink socket. Userspace application will connect to the socket for data transfer. Signed-off-by: Ferruh Yigit --- .../eal/include/exec-env/rte_unci_common.h | 14 ++++++ lib/librte_eal/linuxapp/unci/Makefile | 1 + lib/librte_eal/linuxapp/unci/unci_dev.h | 3 ++ lib/librte_eal/linuxapp/unci/unci_net.c | 2 + lib/librte_eal/linuxapp/unci/unci_nl.c | 55 ++++++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 lib/librte_eal/linuxapp/unci/unci_nl.c diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_unci_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_unci_common.h index d90423a07..a14c463a0 100644 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_unci_common.h +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_unci_common.h @@ -60,6 +60,20 @@ #define UNCI_DEVICE "unci" +#define UNCI_NL_GRP 31 + +#define UNCI_NL_MSG_LEN 500 +struct unci_nl_msg { + uint32_t cmd_id; + uint8_t port_id; + uint32_t flag; + uint8_t input_buffer[UNCI_NL_MSG_LEN]; + uint8_t output_buffer[UNCI_NL_MSG_LEN]; + size_t input_buffer_len; + size_t output_buffer_len; + int err; +}; + enum { IFLA_UNCI_UNSPEC, IFLA_UNCI_PORTID, 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 b0a215f1b..668574167 100644 --- a/lib/librte_eal/linuxapp/unci/unci_dev.h +++ b/lib/librte_eal/linuxapp/unci/unci_dev.h @@ -38,4 +38,7 @@ struct unci_dev { u32 pid; }; +void 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 ee23b0e4d..131769c37 100644 --- a/lib/librte_eal/linuxapp/unci/unci_net.c +++ b/lib/librte_eal/linuxapp/unci/unci_net.c @@ -63,6 +63,7 @@ static struct rtnl_link_ops unci_link_ops __read_mostly = { static int __init unci_init(void) { + unci_nl_init(); return rtnl_link_register(&unci_link_ops); } module_init(unci_init); @@ -70,6 +71,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..9d07e9822 --- /dev/null +++ b/lib/librte_eal/linuxapp/unci/unci_nl.c @@ -0,0 +1,55 @@ +/*- + * 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 + +#include "unci_dev.h" + +static struct sock *nl_sock; +static struct mutex sync_lock; + +static void nl_recv(struct sk_buff *skb) +{ + struct nlmsghdr *nlh; + struct unci_nl_msg nl_msg; + + nlh = (struct nlmsghdr *)skb->data; + + memcpy(&nl_msg, NLMSG_DATA(nlh), sizeof(struct unci_nl_msg)); + pr_debug("CMD: %u\n", nl_msg.cmd_id); +} + +static struct netlink_kernel_cfg cfg = { + .input = nl_recv, +}; + +void unci_nl_init(void) +{ + nl_sock = netlink_kernel_create(&init_net, UNCI_NL_GRP, &cfg); + mutex_init(&sync_lock); +} + +void unci_nl_release(void) +{ + netlink_kernel_release(nl_sock); +}