Skip to contentSkip to conversation

Cisco Systems Inc. VIC Ethernet PMD - ENIC PMD

PATCH Superseded Sujith Sankar 3 participants 18 messages Nov 23, 2014 – Nov 25, 2014 11 messages not in the archive Library code

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover Cisco Systems Inc. VIC Ethernet PMD - ENIC PMD

ENIC PMD is the poll-mode driver for the Cisco Systems Inc. VIC to be used with DPDK suite.

Sujith Sankar (6):
ENIC PMD License
ENIC PMD Makefile
VNIC common code partially shared with ENIC kernel mode driver ENIC PMD specific code
DPDK-ENIC PMD interface
DPDK changes for accommodating ENIC PMD

 config/common_linuxapp                             |    5 +
 lib/Makefile                                       |    1 +
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c         |    7 +
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h |    1 +
 lib/librte_pmd_enic/LICENSE                        |   27 +
 lib/librte_pmd_enic/Makefile                       |   67 +
 lib/librte_pmd_enic/enic.h                         |  158 +++
 lib/librte_pmd_enic/enic_clsf.c                    |  244 ++++
 lib/librte_pmd_enic/enic_compat.h                  |  142 +++
 lib/librte_pmd_enic/enic_etherdev.c                |  613 +++++++++
 lib/librte_pmd_enic/enic_main.c                    | 1328 ++++++++++++++++++++
 lib/librte_pmd_enic/enic_res.c                     |  221 ++++
 lib/librte_pmd_enic/enic_res.h                     |  168 +++
 lib/librte_pmd_enic/vnic/cq_desc.h                 |  126 ++
 lib/librte_pmd_enic/vnic/cq_enet_desc.h            |  261 ++++
 lib/librte_pmd_enic/vnic/rq_enet_desc.h            |   76 ++
 lib/librte_pmd_enic/vnic/vnic_cq.c                 |  117 ++
 lib/librte_pmd_enic/vnic/vnic_cq.h                 |  152 +++
 lib/librte_pmd_enic/vnic/vnic_dev.c                | 1081 ++++++++++++++++
 lib/librte_pmd_enic/vnic/vnic_dev.h                |  202 +++
 lib/librte_pmd_enic/vnic/vnic_devcmd.h             |  774 ++++++++++++
 lib/librte_pmd_enic/vnic/vnic_enet.h               |   78 ++
 lib/librte_pmd_enic/vnic/vnic_intr.c               |   83 ++
 lib/librte_pmd_enic/vnic/vnic_intr.h               |  126 ++
 lib/librte_pmd_enic/vnic/vnic_nic.h                |   88 ++
 lib/librte_pmd_enic/vnic/vnic_resource.h           |   97 ++
 lib/librte_pmd_enic/vnic/vnic_rq.c                 |  246 ++++
 lib/librte_pmd_enic/vnic/vnic_rq.h                 |  282 +++++
 lib/librte_pmd_enic/vnic/vnic_rss.c                |   85 ++
 lib/librte_pmd_enic/vnic/vnic_rss.h                |   61 +
 lib/librte_pmd_enic/vnic/vnic_stats.h              |   86 ++
 lib/librte_pmd_enic/vnic/vnic_wq.c                 |  245 ++++
 lib/librte_pmd_enic/vnic/vnic_wq.h                 |  283 +++++
 lib/librte_pmd_enic/vnic/wq_enet_desc.h            |  114 ++
 mk/rte.app.mk                                      |    4 +
 35 files changed, 7649 insertions(+)
 create mode 100644 lib/librte_pmd_enic/LICENSE
 create mode 100644 lib/librte_pmd_enic/Makefile
 create mode 100644 lib/librte_pmd_enic/enic.h
 create mode 100644 lib/librte_pmd_enic/enic_clsf.c
 create mode 100644 lib/librte_pmd_enic/enic_compat.h
 create mode 100644 lib/librte_pmd_enic/enic_etherdev.c
 create mode 100644 lib/librte_pmd_enic/enic_main.c
 create mode 100644 lib/librte_pmd_enic/enic_res.c
 create mode 100644 lib/librte_pmd_enic/enic_res.h
 create mode 100644 lib/librte_pmd_enic/vnic/cq_desc.h
 create mode 100644 lib/librte_pmd_enic/vnic/cq_enet_desc.h
 create mode 100644 lib/librte_pmd_enic/vnic/rq_enet_desc.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_cq.c
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_cq.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_dev.c
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_dev.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_devcmd.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_enet.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_intr.c
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_intr.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_nic.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_resource.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_rq.c
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_rq.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_rss.c
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_rss.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_stats.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_wq.c
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_wq.h
 create mode 100644 lib/librte_pmd_enic/vnic/wq_enet_desc.h
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): 1416758899-1351-1-git-send-email-ssujith-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH v3 1/6 ENIC PMD License

---
 lib/librte_pmd_enic/LICENSE | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 lib/librte_pmd_enic/LICENSE
lib/librte_pmd_enic/LICENSE new file +27 -0
new file mode 100644
index 0000000..0ad2216
@@ -0,0 +1,27 @@
+ * Copyright (c) 2014, Cisco Systems, Inc. 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
Signature · 1 line
1.9.1
#3 lore raw

PATCH v3 2/6 ENIC PMD Makefile

In reply to a message not in the archive
---
 lib/librte_pmd_enic/Makefile | 67 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 lib/librte_pmd_enic/Makefile
lib/librte_pmd_enic/Makefile new file +67 -0
new file mode 100644
index 0000000..25d8f31
@@ -0,0 +1,67 @@
+#
+# Copyright 2008-2014 Cisco Systems, Inc.  All rights reserved.
+# Copyright 2007 Nuova Systems, Inc.  All rights reserved.
+#
+# Copyright (c) 2014, Cisco Systems, Inc. 
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_pmd_enic.a
+
+CFLAGS += -I$(RTE_SDK)/lib/librte_hash/ -I$(RTE_SDK)/lib/librte_pmd_enic/vnic/
+CFLAGS += -I$(RTE_SDK)/lib/librte_pmd_enic/
+CFLAGS += -O3 -Wno-deprecated
+
+VPATH += $(RTE_SDK)/lib/librte_pmd_enic/src
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += enic_main.c 
+SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += enic_clsf.c 
+SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += vnic/vnic_cq.c 
+SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += vnic/vnic_wq.c 
+SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += vnic/vnic_dev.c 
+SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += vnic/vnic_intr.c 
+SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += vnic/vnic_rq.c 
+SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += enic_etherdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += enic_res.c
+SRCS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += vnic/vnic_rss.c
+
+
+# this lib depends upon:
+DEPDIRS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += lib/librte_eal lib/librte_ether
+DEPDIRS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += lib/librte_mempool lib/librte_mbuf
+DEPDIRS-$(CONFIG_RTE_LIBRTE_ENIC_PMD) += lib/librte_net lib/librte_malloc
+
+include $(RTE_SDK)/mk/rte.lib.mk
+
Signature · 1 line
1.9.1
#4 lore raw

PATCH v3 3/6 VNIC common code partially shared with ENIC kernel mode driver

In reply to a message not in the archive
---
 lib/librte_pmd_enic/vnic/cq_desc.h       |  126 ++++
 lib/librte_pmd_enic/vnic/cq_enet_desc.h  |  261 ++++++++
 lib/librte_pmd_enic/vnic/rq_enet_desc.h  |   76 +++
 lib/librte_pmd_enic/vnic/vnic_cq.c       |  117 ++++
 lib/librte_pmd_enic/vnic/vnic_cq.h       |  152 +++++
 lib/librte_pmd_enic/vnic/vnic_dev.c      | 1081 ++++++++++++++++++++++++++++++
 lib/librte_pmd_enic/vnic/vnic_dev.h      |  202 ++++++
 lib/librte_pmd_enic/vnic/vnic_devcmd.h   |  774 +++++++++++++++++++++
 lib/librte_pmd_enic/vnic/vnic_enet.h     |   78 +++
 lib/librte_pmd_enic/vnic/vnic_intr.c     |   83 +++
 lib/librte_pmd_enic/vnic/vnic_intr.h     |  126 ++++
 lib/librte_pmd_enic/vnic/vnic_nic.h      |   88 +++
 lib/librte_pmd_enic/vnic/vnic_resource.h |   97 +++
 lib/librte_pmd_enic/vnic/vnic_rq.c       |  246 +++++++
 lib/librte_pmd_enic/vnic/vnic_rq.h       |  282 ++++++++
 lib/librte_pmd_enic/vnic/vnic_rss.c      |   85 +++
 lib/librte_pmd_enic/vnic/vnic_rss.h      |   61 ++
 lib/librte_pmd_enic/vnic/vnic_stats.h    |   86 +++
 lib/librte_pmd_enic/vnic/vnic_wq.c       |  245 +++++++
 lib/librte_pmd_enic/vnic/vnic_wq.h       |  283 ++++++++
 lib/librte_pmd_enic/vnic/wq_enet_desc.h  |  114 ++++
 21 files changed, 4663 insertions(+)
 create mode 100644 lib/librte_pmd_enic/vnic/cq_desc.h
 create mode 100644 lib/librte_pmd_enic/vnic/cq_enet_desc.h
 create mode 100644 lib/librte_pmd_enic/vnic/rq_enet_desc.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_cq.c
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_cq.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_dev.c
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_dev.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_devcmd.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_enet.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_intr.c
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_intr.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_nic.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_resource.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_rq.c
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_rq.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_rss.c
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_rss.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_stats.h
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_wq.c
 create mode 100644 lib/librte_pmd_enic/vnic/vnic_wq.h
 create mode 100644 lib/librte_pmd_enic/vnic/wq_enet_desc.h
lib/librte_pmd_enic/vnic/cq_desc.h new file +126 -0
new file mode 100644
index 0000000..7dfb2b6
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2008-2010 Cisco Systems, Inc.  All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
+ *
+ * Copyright (c) 2014, Cisco Systems, Inc. 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#ident "$Id: cq_desc.h 129574 2013-04-26 22:11:14Z rfaucett $"
+
+#ifndef _CQ_DESC_H_
+#define _CQ_DESC_H_
+
+/*
+ * Completion queue descriptor types
+ */
+enum cq_desc_types {
+	CQ_DESC_TYPE_WQ_ENET = 0,
+	CQ_DESC_TYPE_DESC_COPY = 1,
+	CQ_DESC_TYPE_WQ_EXCH = 2,
+	CQ_DESC_TYPE_RQ_ENET = 3,
+	CQ_DESC_TYPE_RQ_FCP = 4,
+	CQ_DESC_TYPE_IOMMU_MISS = 5,
+	CQ_DESC_TYPE_SGL = 6,
+	CQ_DESC_TYPE_CLASSIFIER = 7,
+	CQ_DESC_TYPE_TEST = 127,
+};
+
+/* Completion queue descriptor: 16B
+ *
+ * All completion queues have this basic layout.  The
+ * type_specfic area is unique for each completion
+ * queue type.
+ */
+struct cq_desc {
+	__le16 completed_index;
+	__le16 q_number;
+	u8 type_specfic[11];
+	u8 type_color;
+};
+
+#define CQ_DESC_TYPE_BITS        4
+#define CQ_DESC_TYPE_MASK        ((1 << CQ_DESC_TYPE_BITS) - 1)
+#define CQ_DESC_COLOR_MASK       1
+#define CQ_DESC_COLOR_SHIFT      7
+#define CQ_DESC_Q_NUM_BITS       10
+#define CQ_DESC_Q_NUM_MASK       ((1 << CQ_DESC_Q_NUM_BITS) - 1)
+#define CQ_DESC_COMP_NDX_BITS    12
+#define CQ_DESC_COMP_NDX_MASK    ((1 << CQ_DESC_COMP_NDX_BITS) - 1)
+
+static inline void cq_color_enc(struct cq_desc *desc, const u8 color)
+{
+	if (color)
+		desc->type_color |=  (1 << CQ_DESC_COLOR_SHIFT);
+	else
+		desc->type_color &= ~(1 << CQ_DESC_COLOR_SHIFT);
+}
+
+static inline void cq_desc_enc(struct cq_desc *desc,
+	const u8 type, const u8 color, const u16 q_number,
+	const u16 completed_index)
+{
+	desc->type_color = (type & CQ_DESC_TYPE_MASK) |
+		((color & CQ_DESC_COLOR_MASK) << CQ_DESC_COLOR_SHIFT);
+	desc->q_number = cpu_to_le16(q_number & CQ_DESC_Q_NUM_MASK);
+	desc->completed_index = cpu_to_le16(completed_index &
+		CQ_DESC_COMP_NDX_MASK);
+}
+
+static inline void cq_desc_dec(const struct cq_desc *desc_arg,
+	u8 *type, u8 *color, u16 *q_number, u16 *completed_index)
+{
+	const struct cq_desc *desc = desc_arg;
+	const u8 type_color = desc->type_color;
+
+	*color = (type_color >> CQ_DESC_COLOR_SHIFT) & CQ_DESC_COLOR_MASK;
+
+	/*
+	 * Make sure color bit is read from desc *before* other fields
+	 * are read from desc.  Hardware guarantees color bit is last
+	 * bit (byte) written.  Adding the rmb() prevents the compiler
+	 * and/or CPU from reordering the reads which would potentially
+	 * result in reading stale values.
+	 */
+
+	rmb();
+
+	*type = type_color & CQ_DESC_TYPE_MASK;
+	*q_number = le16_to_cpu(desc->q_number) & CQ_DESC_Q_NUM_MASK;
+	*completed_index = le16_to_cpu(desc->completed_index) &
+		CQ_DESC_COMP_NDX_MASK;
+}
+
+static inline void cq_color_dec(const struct cq_desc *desc_arg, u8 *color)
+{
+	volatile const struct cq_desc *desc = desc_arg;
+
+	*color = (desc->type_color >> CQ_DESC_COLOR_SHIFT) & CQ_DESC_COLOR_MASK;
+}
+
+#endif /* _CQ_DESC_H_ */
lib/librte_pmd_enic/vnic/cq_enet_desc.h new file +261 -0

261 lines not on this page · raw message

lib/librte_pmd_enic/vnic/rq_enet_desc.h new file +76 -0

76 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_cq.c new file +117 -0

117 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_cq.h new file +152 -0

152 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_dev.c new file +1081 -0

1,081 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_dev.h new file +202 -0

202 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_devcmd.h new file +774 -0

774 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_enet.h new file +78 -0

78 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_intr.c new file +83 -0

83 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_intr.h new file +126 -0

50 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_nic.h new file +88 -0

88 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_resource.h new file +97 -0

97 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_rq.c new file +246 -0

246 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_rq.h new file +282 -0

282 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_rss.c new file +85 -0

85 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_rss.h new file +61 -0

61 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_stats.h new file +86 -0

86 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_wq.c new file +245 -0

245 lines not on this page · raw message

lib/librte_pmd_enic/vnic/vnic_wq.h new file +283 -0

283 lines not on this page · raw message

lib/librte_pmd_enic/vnic/wq_enet_desc.h new file +114 -0

114 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.9.1

Part of the diff is not shown here. View the raw message.

#5 lore raw

PATCH v3 4/6 ENIC PMD specific code

In reply to a message not in the archive
---
 lib/librte_pmd_enic/enic.h        |  158 +++++
 lib/librte_pmd_enic/enic_clsf.c   |  244 +++++++
 lib/librte_pmd_enic/enic_compat.h |  142 ++++
 lib/librte_pmd_enic/enic_main.c   | 1328 +++++++++++++++++++++++++++++++++++++
 lib/librte_pmd_enic/enic_res.c    |  221 ++++++
 lib/librte_pmd_enic/enic_res.h    |  168 +++++
 6 files changed, 2261 insertions(+)
 create mode 100644 lib/librte_pmd_enic/enic.h
 create mode 100644 lib/librte_pmd_enic/enic_clsf.c
 create mode 100644 lib/librte_pmd_enic/enic_compat.h
 create mode 100644 lib/librte_pmd_enic/enic_main.c
 create mode 100644 lib/librte_pmd_enic/enic_res.c
 create mode 100644 lib/librte_pmd_enic/enic_res.h
lib/librte_pmd_enic/enic.h new file +158 -0
new file mode 100644
index 0000000..b72c048
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2008-2014 Cisco Systems, Inc.  All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
+ *
+ * Copyright (c) 2014, Cisco Systems, Inc. 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#ident "$Id$"
+
+#ifndef _ENIC_H_
+#define _ENIC_H_
+
+#include "vnic_enet.h"
+#include "vnic_dev.h"
+#include "vnic_wq.h"
+#include "vnic_rq.h"
+#include "vnic_cq.h"
+#include "vnic_intr.h"
+#include "vnic_stats.h"
+#include "vnic_nic.h"
+#include "vnic_rss.h"
+#include "enic_res.h"
+
+#define DRV_NAME		"enic_pmd"
+#define DRV_DESCRIPTION		"Cisco VIC Ethernet NIC Poll-mode Driver"
+#define DRV_VERSION		"1.0.0.4"
+#define DRV_COPYRIGHT		"Copyright 2008-2014 Cisco Systems, Inc"
+
+#define ENIC_WQ_MAX		8
+#define ENIC_RQ_MAX		8
+#define ENIC_CQ_MAX		(ENIC_WQ_MAX + ENIC_RQ_MAX)
+#define ENIC_INTR_MAX		(ENIC_CQ_MAX + 2)
+
+#define VLAN_ETH_HLEN           18
+
+#define ENICPMD_SETTING(enic, f) ((enic->config.flags & VENETF_##f) ? 1 : 0)
+
+#define ENICPMD_BDF_LENGTH      13   /* 0000:00:00.0'\0' */
+#define PKT_TX_TCP_UDP_CKSUM    0x6000
+#define ENIC_CALC_IP_CKSUM      1
+#define ENIC_CALC_TCP_UDP_CKSUM 2
+#define ENIC_MAX_MTU            9000
+#define PAGE_SIZE               4096
+#define PAGE_ROUND_UP(x) \
+	((((unsigned long)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)))
+
+#define ENICPMD_VFIO_PATH          "/dev/vfio/vfio"
+/*#define ENIC_DESC_COUNT_MAKE_ODD (x) do{if ((~(x)) & 1) { (x)--; } }while(0)*/
+
+#define PCI_DEVICE_ID_CISCO_VIC_ENET         0x0043  /* ethernet vnic */
+#define PCI_DEVICE_ID_CISCO_VIC_ENET_VF      0x0071  /* enet SRIOV VF */
+
+
+#define ENICPMD_FDIR_MAX           64
+
+struct enic_fdir_node {
+	struct rte_fdir_filter filter;
+	u16 fltr_id;
+	u16 rq_index;
+};
+
+struct enic_fdir {
+	struct rte_eth_fdir stats;
+	struct rte_hash *hash;
+	struct enic_fdir_node *nodes[ENICPMD_FDIR_MAX];
+};
+
+/* Per-instance private data structure */
+struct enic {
+	struct enic *next;
+	struct rte_pci_device *pdev;
+	struct vnic_enet_config config;
+	struct vnic_dev_bar bar0;
+	struct vnic_dev *vdev;
+
+	struct rte_eth_dev *rte_dev;
+	struct enic_fdir fdir;
+	char bdf_name[ENICPMD_BDF_LENGTH];
+	int dev_fd;
+	int iommu_group_fd;
+	int vfio_fd;
+	int iommu_groupid;
+	int eventfd;
+	u_int8_t mac_addr[ETH_ALEN];
+	pthread_t err_intr_thread;
+	int promisc;
+	int allmulti;
+	int ig_vlan_strip_en;
+	int link_status;
+	u8 hw_ip_checksum;
+
+	unsigned int flags;
+	unsigned int priv_flags;
+
+	/* work queue */
+	struct vnic_wq wq[ENIC_WQ_MAX];
+	unsigned int wq_count;
+
+	/* receive queue */
+	struct vnic_rq rq[ENIC_RQ_MAX];
+	unsigned int rq_count;
+
+	/* completion queue */
+	struct vnic_cq cq[ENIC_CQ_MAX];
+	unsigned int cq_count;
+
+	/* interrupt resource */
+	struct vnic_intr intr;
+	unsigned int intr_count;
+};
+
+static inline unsigned int enic_cq_rq(struct enic *enic, unsigned int rq)
+{
+	return rq;
+}
+
+static inline unsigned int enic_cq_wq(struct enic *enic, unsigned int wq)
+{
+	return enic->rq_count + wq;
+}
+
+static inline unsigned int enic_msix_err_intr(struct enic *enic)
+{
+	return 0;
+}
+
+static inline struct enic *pmd_priv(struct rte_eth_dev *eth_dev)
+{
+	return (struct enic *)eth_dev->data->dev_private;
+}
+
+#endif /* _ENIC_H_ */
lib/librte_pmd_enic/enic_clsf.c new file +244 -0

244 lines not on this page · raw message

lib/librte_pmd_enic/enic_compat.h new file +142 -0

142 lines not on this page · raw message

lib/librte_pmd_enic/enic_main.c new file +1328 -0

1,328 lines not on this page · raw message

lib/librte_pmd_enic/enic_res.c new file +221 -0

221 lines not on this page · raw message

lib/librte_pmd_enic/enic_res.h new file +168 -0

168 lines not on this page · raw message

Signature · 1 line
1.9.1
#6 lore raw

PATCH v3 5/6 DPDK-ENIC PMD interface

In reply to a message not in the archive
---
 lib/librte_pmd_enic/enic_etherdev.c | 613 ++++++++++++++++++++++++++++++++++++
 1 file changed, 613 insertions(+)
 create mode 100644 lib/librte_pmd_enic/enic_etherdev.c
lib/librte_pmd_enic/enic_etherdev.c new file +613 -0
new file mode 100644
index 0000000..441c85a
@@ -0,0 +1,613 @@
+/*
+ * Copyright 2008-2014 Cisco Systems, Inc.  All rights reserved.
+ * Copyright 2007 Nuova Systems, Inc.  All rights reserved.
+ *
+ * Copyright (c) 2014, Cisco Systems, Inc. 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+#ident "$Id$"
+
+#include <stdio.h>
+#include <stdint.h>
+
+#include <rte_dev.h>
+#include <rte_pci.h>
+#include <rte_ethdev.h>
+#include <rte_string_fns.h>
+
+#include "vnic_intr.h"
+#include "vnic_cq.h"
+#include "vnic_wq.h"
+#include "vnic_rq.h"
+#include "vnic_enet.h"
+#include "enic.h"
+
+#define ENICPMD_FUNC_TRACE() \
+    RTE_LOG(DEBUG, PMD, "ENICPMD trace: %s\n", __func__)
+
+/*
+ * The set of PCI devices this driver supports
+ */
+static struct rte_pci_id pci_id_enic_map[] = {
+#define RTE_PCI_DEV_ID_DECL_ENIC(vend, dev) {RTE_PCI_DEVICE(vend, dev)},
+#ifndef PCI_VENDOR_ID_CISCO
+#define PCI_VENDOR_ID_CISCO	0x1137
+#endif
+#include "rte_pci_dev_ids.h"
+RTE_PCI_DEV_ID_DECL_ENIC(PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET)
+RTE_PCI_DEV_ID_DECL_ENIC(PCI_VENDOR_ID_CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET_VF)
+{.vendor_id = 0, /* Sentinal */},
+};
+
+static int enicpmd_fdir_remove_perfect_filter(struct rte_eth_dev *eth_dev,
+		struct rte_fdir_filter *fdir_filter,
+		uint16_t soft_id)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	return enic_fdir_del_fltr(enic, fdir_filter);
+}
+
+static int enicpmd_fdir_add_perfect_filter(struct rte_eth_dev *eth_dev,
+	struct rte_fdir_filter *fdir_filter, uint16_t soft_id,
+	uint8_t queue, uint8_t drop)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	return enic_fdir_add_fltr(enic, fdir_filter, (uint16_t)queue, drop);
+}
+
+static void enicpmd_fdir_info_get(struct rte_eth_dev *eth_dev,
+	struct rte_eth_fdir *fdir)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	*fdir = enic->fdir.stats;
+}
+
+static void enicpmd_dev_tx_queue_release(void *txq)
+{
+	ENICPMD_FUNC_TRACE();
+	enic_free_wq(txq);
+}
+
+static int enicpmd_dev_setup_intr(struct enic *enic)
+{
+	int ret;
+	int index;
+
+	ENICPMD_FUNC_TRACE();
+
+	/* Are we done with the init of all the queues? */
+	for (index = 0; index < enic->cq_count; index++) {
+		if (!enic->cq[index].ctrl)
+			break;
+	}
+
+	if (enic->cq_count != index)
+		return 0;
+
+	ret = enic_alloc_intr_resources(enic);
+	if (ret) {
+		dev_err(enic, "alloc intr failed\n");
+		return ret;
+	}
+	enic_init_vnic_resources(enic);
+
+	ret = enic_setup_finish(enic);
+	if (ret)
+		dev_err(enic, "setup could not be finished\n");
+
+	return ret;
+}
+
+static int enicpmd_dev_tx_queue_setup(struct rte_eth_dev *eth_dev,
+	uint16_t queue_idx,
+	uint16_t nb_desc,
+	unsigned int socket_id,
+	const struct rte_eth_txconf *tx_conf)
+{
+	int ret;
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	eth_dev->data->tx_queues[queue_idx] = (void *)&enic->wq[queue_idx];
+
+	ret = enic_alloc_wq(enic, queue_idx, socket_id, nb_desc);
+	if (ret) {
+		dev_err(enic, "error in allocating wq\n");
+		return ret;
+	}
+
+	return enicpmd_dev_setup_intr(enic);
+}
+
+static int enicpmd_dev_tx_queue_start(struct rte_eth_dev *eth_dev,
+	uint16_t queue_idx)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+
+	enic_start_wq(enic, queue_idx);
+
+	return 0;
+}
+
+static int enicpmd_dev_tx_queue_stop(struct rte_eth_dev *eth_dev,
+	uint16_t queue_idx)
+{
+	int ret;
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+
+	ret = enic_stop_wq(enic, queue_idx);
+	if (ret)
+		dev_err(enic, "error in stopping wq %d\n", queue_idx);
+
+	return ret;
+}
+
+static int enicpmd_dev_rx_queue_start(struct rte_eth_dev *eth_dev,
+	uint16_t queue_idx)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+
+	enic_start_rq(enic, queue_idx);
+
+	return 0;
+}
+
+static int enicpmd_dev_rx_queue_stop(struct rte_eth_dev *eth_dev,
+	uint16_t queue_idx)
+{
+	int ret;
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+
+	ret = enic_stop_rq(enic, queue_idx);
+	if (ret)
+		dev_err(enic, "error in stopping rq %d\n", queue_idx);
+
+	return ret;
+}
+
+static void enicpmd_dev_rx_queue_release(void *rxq)
+{
+	ENICPMD_FUNC_TRACE();
+	enic_free_rq(rxq);
+}
+
+static int enicpmd_dev_rx_queue_setup(struct rte_eth_dev *eth_dev,
+	uint16_t queue_idx,
+	uint16_t nb_desc,
+	unsigned int socket_id,
+	const struct rte_eth_rxconf *rx_conf,
+	struct rte_mempool *mp)
+{
+	int ret;
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	eth_dev->data->rx_queues[queue_idx] = (void *)&enic->rq[queue_idx];
+
+	ret = enic_alloc_rq(enic, queue_idx, socket_id, mp, nb_desc);
+	if (ret) {
+		dev_err(enic, "error in allocating rq\n");
+		return ret;
+	}
+
+	return enicpmd_dev_setup_intr(enic);
+}
+
+static int enicpmd_vlan_filter_set(struct rte_eth_dev *eth_dev,
+	uint16_t vlan_id, int on)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	if (on)
+		enic_add_vlan(enic, vlan_id);
+	else
+		enic_del_vlan(enic, vlan_id);
+	return 0;
+}
+
+static void enicpmd_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+
+	if (mask & ETH_VLAN_STRIP_MASK) {
+		if (eth_dev->data->dev_conf.rxmode.hw_vlan_strip)
+			enic->ig_vlan_strip_en = 1;
+		else
+			enic->ig_vlan_strip_en = 0;
+	}
+	enic_set_rss_nic_cfg(enic);
+
+
+	if (mask & ETH_VLAN_FILTER_MASK) {
+		dev_warning(enic,
+			"Configuration of VLAN filter is not supported\n");
+	}
+
+	if (mask & ETH_VLAN_EXTEND_MASK) {
+		dev_warning(enic,
+			"Configuration of extended VLAN is not supported\n");
+	}
+}
+
+static int enicpmd_dev_configure(struct rte_eth_dev *eth_dev)
+{
+	int ret;
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	ret = enic_set_vnic_res(enic);
+	if (ret) {
+		dev_err(enic, "Set vNIC resource num  failed, aborting\n");
+		return ret;
+	}
+
+	if (eth_dev->data->dev_conf.rxmode.split_hdr_size &&
+		eth_dev->data->dev_conf.rxmode.header_split) {
+		/* Enable header-data-split */
+		enic_set_hdr_split_size(enic,
+			eth_dev->data->dev_conf.rxmode.split_hdr_size);
+	}
+
+	enic->hw_ip_checksum = eth_dev->data->dev_conf.rxmode.hw_ip_checksum;
+	return 0;
+}
+
+/* Start the device.
+ * It returns 0 on success.
+ */
+static int enicpmd_dev_start(struct rte_eth_dev *eth_dev)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	return enic_enable(enic);
+}
+
+/*
+ * Stop device: disable rx and tx functions to allow for reconfiguring.
+ */
+static void enicpmd_dev_stop(struct rte_eth_dev *eth_dev)
+{
+	struct rte_eth_link link;
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	enic_disable(enic);
+	memset(&link, 0, sizeof(link));
+	rte_atomic64_cmpset((uint64_t *)&eth_dev->data->dev_link,
+		*(uint64_t *)&eth_dev->data->dev_link,
+		*(uint64_t *)&link);
+}
+
+/*
+ * Stop device.
+ */
+static void enicpmd_dev_close(struct rte_eth_dev *eth_dev)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	enic_remove(enic);
+}
+
+static int enicpmd_dev_link_update(struct rte_eth_dev *eth_dev,
+	int wait_to_complete)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+	int ret;
+	int link_status = 0;
+
+	ENICPMD_FUNC_TRACE();
+	link_status = enic_get_link_status(enic);
+	ret = (link_status == enic->link_status);
+	enic->link_status = link_status;
+	eth_dev->data->dev_link.link_status = link_status;
+	eth_dev->data->dev_link.link_duplex = ETH_LINK_FULL_DUPLEX;
+	eth_dev->data->dev_link.link_speed = vnic_dev_port_speed(enic->vdev);
+	return ret;
+}
+
+static void enicpmd_dev_stats_get(struct rte_eth_dev *eth_dev,
+	struct rte_eth_stats *stats)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	enic_dev_stats_get(enic, stats);
+}
+
+static void enicpmd_dev_stats_reset(struct rte_eth_dev *eth_dev)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	enic_dev_stats_clear(enic);
+}
+
+static void enicpmd_dev_info_get(struct rte_eth_dev *eth_dev,
+	struct rte_eth_dev_info *device_info)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	device_info->max_rx_queues = enic->rq_count;
+	device_info->max_tx_queues = enic->wq_count;
+	device_info->min_rx_bufsize = ENIC_MIN_MTU;
+	device_info->max_rx_pktlen = enic->config.mtu;
+	device_info->max_mac_addrs = 1;
+	device_info->rx_offload_capa =
+		DEV_RX_OFFLOAD_VLAN_STRIP |
+		DEV_RX_OFFLOAD_IPV4_CKSUM |
+		DEV_RX_OFFLOAD_UDP_CKSUM  |
+		DEV_RX_OFFLOAD_TCP_CKSUM;
+	device_info->tx_offload_capa =
+		DEV_TX_OFFLOAD_VLAN_INSERT |
+		DEV_TX_OFFLOAD_IPV4_CKSUM  |
+		DEV_TX_OFFLOAD_UDP_CKSUM   |
+		DEV_TX_OFFLOAD_TCP_CKSUM;
+}
+
+static void enicpmd_dev_promiscuous_enable(struct rte_eth_dev *eth_dev)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	enic->promisc = 1;
+	enic_add_packet_filter(enic);
+}
+
+static void enicpmd_dev_promiscuous_disable(struct rte_eth_dev *eth_dev)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	enic->promisc = 0;
+	enic_add_packet_filter(enic);
+}
+
+static void enicpmd_dev_allmulticast_enable(struct rte_eth_dev *eth_dev)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	enic->allmulti = 1;
+	enic_add_packet_filter(enic);
+}
+
+static void enicpmd_dev_allmulticast_disable(struct rte_eth_dev *eth_dev)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	enic->allmulti = 0;
+	enic_add_packet_filter(enic);
+}
+
+static void enicpmd_add_mac_addr(struct rte_eth_dev *eth_dev,
+	struct ether_addr *mac_addr,
+	uint32_t index, uint32_t pool)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	enic_set_mac_address(enic, mac_addr->addr_bytes);
+}
+
+static void enicpmd_remove_mac_addr(struct rte_eth_dev *eth_dev, uint32_t index)
+{
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+	enic_del_mac_address(enic);
+}
+
+
+static uint16_t enicpmd_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
+	uint16_t nb_pkts)
+{
+	unsigned int index;
+	unsigned int frags;
+	unsigned int pkt_len;
+	unsigned int seg_len;
+	unsigned int inc_len;
+	unsigned int nb_segs;
+	struct rte_mbuf *tx_pkt;
+	struct vnic_wq *wq = (struct vnic_wq *)tx_queue;
+	struct enic *enic = vnic_dev_priv(wq->vdev);
+	unsigned char *buf;
+	unsigned short vlan_id;
+	unsigned short ol_flags;
+
+	for (index = 0; index < nb_pkts; index++) {
+		tx_pkt = *tx_pkts++;
+		inc_len = 0;
+		nb_segs = tx_pkt->nb_segs;
+		if (nb_segs > vnic_wq_desc_avail(wq)) {
+			/* wq cleanup and try again */
+			if (!enic_cleanup_wq(enic, wq) ||
+				(nb_segs > vnic_wq_desc_avail(wq)))
+				return index;
+		}
+		pkt_len = tx_pkt->pkt_len;
+		vlan_id = tx_pkt->vlan_tci;
+		ol_flags = tx_pkt->ol_flags;
+		for (frags = 0; inc_len < pkt_len; frags++) {
+			if (!tx_pkt)
+				break;
+			seg_len = tx_pkt->data_len;
+			inc_len += seg_len;
+			if (enic_send_pkt(enic, wq, tx_pkt,
+				    (unsigned short)seg_len, !frags,
+				    (pkt_len == inc_len), ol_flags, vlan_id)) {
+				break;
+			}
+			tx_pkt = tx_pkt->next;
+		}
+	}
+
+	enic_cleanup_wq(enic, wq);
+	return index;
+}
+
+static uint16_t enicpmd_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
+	uint16_t nb_pkts)
+{
+	struct vnic_rq *rq = (struct vnic_rq *)rx_queue;
+	unsigned int work_done;
+
+	if (enic_poll(rq, rx_pkts, (unsigned int)nb_pkts, &work_done))
+		dev_err(enic, "error in enicpmd poll\n");
+
+	return work_done;
+}
+
+static struct eth_dev_ops enicpmd_eth_dev_ops = {
+	.dev_configure        = enicpmd_dev_configure,
+	.dev_start            = enicpmd_dev_start,
+	.dev_stop             = enicpmd_dev_stop,
+	.dev_set_link_up      = NULL,
+	.dev_set_link_down    = NULL,
+	.dev_close            = enicpmd_dev_close,
+	.promiscuous_enable   = enicpmd_dev_promiscuous_enable,
+	.promiscuous_disable  = enicpmd_dev_promiscuous_disable,
+	.allmulticast_enable  = enicpmd_dev_allmulticast_enable,
+	.allmulticast_disable = enicpmd_dev_allmulticast_disable,
+	.link_update          = enicpmd_dev_link_update,
+	.stats_get            = enicpmd_dev_stats_get,
+	.stats_reset          = enicpmd_dev_stats_reset,
+	.queue_stats_mapping_set = NULL,
+	.dev_infos_get        = enicpmd_dev_info_get,
+	.mtu_set              = NULL,
+	.vlan_filter_set      = enicpmd_vlan_filter_set,
+	.vlan_tpid_set        = NULL,
+	.vlan_offload_set     = enicpmd_vlan_offload_set,
+	.vlan_strip_queue_set = NULL,
+	.rx_queue_start       = enicpmd_dev_rx_queue_start,
+	.rx_queue_stop        = enicpmd_dev_rx_queue_stop,
+	.tx_queue_start       = enicpmd_dev_tx_queue_start,
+	.tx_queue_stop        = enicpmd_dev_tx_queue_stop,
+	.rx_queue_setup       = enicpmd_dev_rx_queue_setup,
+	.rx_queue_release     = enicpmd_dev_rx_queue_release,
+	.rx_queue_count       = NULL,
+	.rx_descriptor_done   = NULL,
+	.tx_queue_setup       = enicpmd_dev_tx_queue_setup,
+	.tx_queue_release     = enicpmd_dev_tx_queue_release,
+	.dev_led_on           = NULL,
+	.dev_led_off          = NULL,
+	.flow_ctrl_get        = NULL,
+	.flow_ctrl_set        = NULL,
+	.priority_flow_ctrl_set = NULL,
+	.mac_addr_add         = enicpmd_add_mac_addr,
+	.mac_addr_remove      = enicpmd_remove_mac_addr,
+	.fdir_add_signature_filter    = NULL,
+	.fdir_update_signature_filter = NULL,
+	.fdir_remove_signature_filter = NULL,
+	.fdir_infos_get               = enicpmd_fdir_info_get,
+	.fdir_add_perfect_filter      = enicpmd_fdir_add_perfect_filter,
+	.fdir_update_perfect_filter   = enicpmd_fdir_add_perfect_filter,
+	.fdir_remove_perfect_filter   = enicpmd_fdir_remove_perfect_filter,
+	.fdir_set_masks               = NULL,
+};
+
+struct enic *enicpmd_list_head = NULL;
+/* Initialize the driver
+ * It returns 0 on success.
+ */
+static int eth_enicpmd_dev_init(
+	__attribute__((unused))struct eth_driver *eth_drv,
+	struct rte_eth_dev *eth_dev)
+{
+	struct rte_pci_device *pdev;
+	struct rte_pci_addr *addr;
+	struct enic *enic = pmd_priv(eth_dev);
+
+	ENICPMD_FUNC_TRACE();
+
+	enic->rte_dev = eth_dev;
+	eth_dev->dev_ops = &enicpmd_eth_dev_ops;
+	eth_dev->rx_pkt_burst = &enicpmd_recv_pkts;
+	eth_dev->tx_pkt_burst = &enicpmd_xmit_pkts;
+
+	pdev = eth_dev->pci_dev;
+	enic->pdev = pdev;
+	addr = &pdev->addr;
+
+	snprintf(enic->bdf_name, ENICPMD_BDF_LENGTH, "%04x:%02x:%02x.%x",
+		addr->domain, addr->bus, addr->devid, addr->function);
+
+	return enic_probe(enic);
+}
+
+static struct eth_driver rte_enic_pmd = {
+	{
+		.name = "rte_enic_pmd",
+		.id_table = pci_id_enic_map,
+		.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+	},
+	.eth_dev_init = eth_enicpmd_dev_init,
+	.dev_private_size = sizeof(struct enic),
+};
+
+/* Driver initialization routine.
+ * Invoked once at EAL init time.
+ * Register as the [Poll Mode] Driver of Cisco ENIC device.
+ */
+int rte_enic_pmd_init(const char *name __rte_unused,
+	const char *params __rte_unused)
+{
+	ENICPMD_FUNC_TRACE();
+
+	rte_eth_driver_register(&rte_enic_pmd);
+	return 0;
+}
+
+static struct rte_driver rte_enic_driver = {
+	.type = PMD_PDEV,
+	.init = rte_enic_pmd_init,
+};
+
+PMD_REGISTER_DRIVER(rte_enic_driver);
+
Signature · 1 line
1.9.1
#7 lore raw

PATCH v3 6/6 DPDK changes for accommodating ENIC PMD

In reply to a message not in the archive
---
 config/common_linuxapp                             | 5 +++++
 lib/Makefile                                       | 1 +
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c         | 7 +++++++
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h | 1 +
 mk/rte.app.mk                                      | 4 ++++
 5 files changed, 18 insertions(+)
config/common_linuxapp +5 -0
index 57b61c9..3c091e7 100644
@@ -210,6 +210,11 @@ CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=4
 CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
 
 #
+# Compile burst-oriented Cisco ENIC PMD driver
+#
+CONFIG_RTE_LIBRTE_ENIC_PMD=y
+
+#
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
lib/Makefile +1 -0
index e3237ff..1911790 100644
@@ -43,6 +43,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
 DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
+DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_enic
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +7 -0
index c776ddc..6bf8f2e 100644
@@ -736,6 +736,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 		maps[i].offset = reg.offset;
 		maps[i].size = reg.size;
 		dev->mem_resource[i].addr = bar_addr;
+		dev->mem_resource[i].len = reg.size;
 	}
 
 	/* if secondary process, do not set up interrupts */
@@ -791,4 +792,10 @@ pci_vfio_is_enabled(void)
 {
 	return vfio_cfg.vfio_enabled;
 }
+
+int
+pci_vfio_container_fd(void)
+{
+	return vfio_cfg.vfio_container_fd;
+}
 #endif
lib/librte_eal/linuxapp/eal/include/eal_pci_init.h +1 -0
index d758bee..c9e9e40 100644
@@ -71,6 +71,7 @@ int pci_uio_map_resource(struct rte_pci_device *dev);
 
 int pci_vfio_enable(void);
 int pci_vfio_is_enabled(void);
+int pci_vfio_container_fd(void);
 int pci_vfio_mp_sync_setup(void);
 
 /* map VFIO resource prototype */
mk/rte.app.mk +4 -0
index 285b65c..95c652f 100644
@@ -186,6 +186,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_VMXNET3_PMD),y)
 LDLIBS += -lrte_pmd_vmxnet3_uio
 endif
 
+ifeq ($(CONFIG_RTE_LIBRTE_ENIC_PMD),y)
+LDLIBS += -lrte_pmd_enic
+endif
+
 ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
 LDLIBS += -lrte_pmd_virtio_uio
 endif
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): 1416758899-1351-7-git-send-email-ssujith-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org

#9 lore raw

Re: [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

Quoted 50 lines · Sujith Sankar
---
 config/common_linuxapp                             | 5 +++++
 lib/Makefile                                       | 1 +
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c         | 7 +++++++
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h | 1 +
 mk/rte.app.mk                                      | 4 ++++
 5 files changed, 18 insertions(+)
config/common_linuxapp +5 -0
index 57b61c9..3c091e7 100644
@@ -210,6 +210,11 @@ CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=4
 CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
 
 #
+# Compile burst-oriented Cisco ENIC PMD driver
+#
+CONFIG_RTE_LIBRTE_ENIC_PMD=y
+
+#
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
lib/Makefile +1 -0
index e3237ff..1911790 100644
@@ -43,6 +43,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
 DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
+DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_enic
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -0
index c776ddc..6bf8f2e 100644
@@ -736,6 +736,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 		maps[i].offset = reg.offset;
 		maps[i].size = reg.size;
 		dev->mem_resource[i].addr = bar_addr;
+		dev->mem_resource[i].len = reg.size;
 	}
 
 	/* if secondary process, do not set up interrupts */

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c pci_vfio_is_enabled(void) · line 800

Quoted 9 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +6 -0
@@ -791,4 +792,10 @@ pci_vfio_is_enabled(void)
 {
 	return vfio_cfg.vfio_enabled;
 }
+
+int
+pci_vfio_container_fd(void)
+{
+	return vfio_cfg.vfio_container_fd;
+}

You should move this function definition to a separate patch and put it earlier in the series, as you call this function two patches back.

Also, this gives me pause, as it seems like you're working around the VFIO api.

Quoted 1 line

From what I see, you just use this to get an fd that you can use in an ioctl to

set some DMA settings. First off, theres already a function called pci_vfio_get_container_fd, which does exactly what you are doing here, with additional safety checking.

However, even though there is an existing function to do what you want, I would recommend that you not use it for your purposes. Whenever you expose something like a file descriptor, you run the risk of multiple accessors racing trying to set/unset features and preform operations. It would be better if you could add apropriate api calls to vfio interface to set what you want. That way the library can add appropriate locking if/when needed

Neil

Quoted 32 lines

#endif

lib/librte_eal/linuxapp/eal/include/eal_pci_init.h +1 -0
index d758bee..c9e9e40 100644
@@ -71,6 +71,7 @@ int pci_uio_map_resource(struct rte_pci_device *dev);
 
 int pci_vfio_enable(void);
 int pci_vfio_is_enabled(void);
+int pci_vfio_container_fd(void);
 int pci_vfio_mp_sync_setup(void);
 
 /* map VFIO resource prototype */
mk/rte.app.mk +4 -0
index 285b65c..95c652f 100644
@@ -186,6 +186,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_VMXNET3_PMD),y)
 LDLIBS += -lrte_pmd_vmxnet3_uio
 endif
 
+ifeq ($(CONFIG_RTE_LIBRTE_ENIC_PMD),y)
+LDLIBS += -lrte_pmd_enic
+endif
+
 ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
 LDLIBS += -lrte_pmd_virtio_uio
 endif
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): 20141124001744.GA7751-bi+AKbBUZKY6gyzm1THtWbp2dZbC/[email protected]

#11 lore raw

Re: [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

Quoted 50 lines · Neil Horman
Quoted 49 lines · Sujith Sankar
---
 config/common_linuxapp                             | 5 +++++
 lib/Makefile                                       | 1 +
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c         | 7 +++++++
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h | 1 +
 mk/rte.app.mk                                      | 4 ++++
 5 files changed, 18 insertions(+)
config/common_linuxapp +5 -0
index 57b61c9..3c091e7 100644
@@ -210,6 +210,11 @@ CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=4
 CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
 
 #
+# Compile burst-oriented Cisco ENIC PMD driver
+#
+CONFIG_RTE_LIBRTE_ENIC_PMD=y
+
+#
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
lib/Makefile +1 -0
index e3237ff..1911790 100644
@@ -43,6 +43,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
 DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
+DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_enic
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -0
index c776ddc..6bf8f2e 100644
@@ -736,6 +736,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 		maps[i].offset = reg.offset;
 		maps[i].size = reg.size;
 		dev->mem_resource[i].addr = bar_addr;
+		dev->mem_resource[i].len = reg.size;
 	}
 
Quoted 14 lines

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c pci_vfio_is_enabled(void) · line 800

Quoted 11 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +6 -0
 	/* if secondary process, do not set up interrupts */
@@ -791,4 +792,10 @@ pci_vfio_is_enabled(void)
 {
 	return vfio_cfg.vfio_enabled;
 }
+
+int
+pci_vfio_container_fd(void)
+{
+	return vfio_cfg.vfio_container_fd;
+}

You should move this function definition to a separate patch and put it earlier
in the series, as you call this function two patches back.

Thanks for the comment, Neil. I shall move this to a separate patch and put it earlier in the series.

Quoted 10 lines

Also, this gives me pause, as it seems like you're working around the VFIO api.
From what I see, you just use this to get an fd that you can use in an ioctl to
set some DMA settings. First off, theres already a function called pci_vfio_get_container_fd, which does exactly what you are doing here, with
additional safety checking.

Quoted 10 lines

However, even though there is an existing function to do what you want, I would
recommend that you not use it for your purposes. Whenever you expose something
like a file descriptor, you run the risk of multiple accessors racing trying to
set/unset features and preform operations. It would be better if you could add
apropriate api calls to vfio interface to set what you want. That way the library can add appropriate locking if/when needed

I see that vfio_cfg.vfio_container_fd is obtained and stored in pci_vfio_enable(), and this is not modified later.
ENIC PMD needs it to add the IOMMU mapping for buffers used for communicating with adapter firmware. That¹s just adding an entry, and container fd is just passed as an argument. So the following addition in eal_pci_vfio.c should be sufficient. Since vfio_cfg is per process, I do not think that any other checking is required.

int
pci_vfio_map_dma(struct vfio_iommu_type1_dma_map *dma_map)

{
	return ioctl(vfio_cfg.vfio_container_fd, VFIO_IOMMU_MAP_DMA, dma_map);
}

Does this look alright? Do you think that I¹ve missed out anything here?

Thanks,
-Sujith

Quoted 36 lines

Neil

Quoted 33 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +0 -0
 #endif
lib/librte_eal/linuxapp/eal/include/eal_pci_init.h +1 -0
index d758bee..c9e9e40 100644
@@ -71,6 +71,7 @@ int pci_uio_map_resource(struct rte_pci_device *dev);
 
 int pci_vfio_enable(void);
 int pci_vfio_is_enabled(void);
+int pci_vfio_container_fd(void);
 int pci_vfio_mp_sync_setup(void);
 
 /* map VFIO resource prototype */
mk/rte.app.mk +4 -0
index 285b65c..95c652f 100644
@@ -186,6 +186,10 @@ ifeq ($(CONFIG_RTE_LIBRTE_VMXNET3_PMD),y)
 LDLIBS += -lrte_pmd_vmxnet3_uio
 endif
 
+ifeq ($(CONFIG_RTE_LIBRTE_ENIC_PMD),y)
+LDLIBS += -lrte_pmd_enic
+endif
+
 ifeq ($(CONFIG_RTE_LIBRTE_VIRTIO_PMD),y)
 LDLIBS += -lrte_pmd_virtio_uio
 endif
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): D098AD4B.28692%[email protected]

#13 lore raw

Re: [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

Quoted 104 lines · Sujith Sankar (ssujith)
Quoted 50 lines · Neil Horman
Quoted 49 lines · Sujith Sankar
---
 config/common_linuxapp                             | 5 +++++
 lib/Makefile                                       | 1 +
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c         | 7 +++++++
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h | 1 +
 mk/rte.app.mk                                      | 4 ++++
 5 files changed, 18 insertions(+)
config/common_linuxapp +5 -0
index 57b61c9..3c091e7 100644
@@ -210,6 +210,11 @@ CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=4
 CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
 
 #
+# Compile burst-oriented Cisco ENIC PMD driver
+#
+CONFIG_RTE_LIBRTE_ENIC_PMD=y
+
+#
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
lib/Makefile +1 -0
index e3237ff..1911790 100644
@@ -43,6 +43,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
 DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
+DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_enic
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -0
index c776ddc..6bf8f2e 100644
@@ -736,6 +736,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 		maps[i].offset = reg.offset;
 		maps[i].size = reg.size;
 		dev->mem_resource[i].addr = bar_addr;
+		dev->mem_resource[i].len = reg.size;
 	}
 
Quoted 14 lines

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c pci_vfio_is_enabled(void) · line 800

Quoted 11 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +6 -0
 	/* if secondary process, do not set up interrupts */
@@ -791,4 +792,10 @@ pci_vfio_is_enabled(void)
 {
 	return vfio_cfg.vfio_enabled;
 }
+
+int
+pci_vfio_container_fd(void)
+{
+	return vfio_cfg.vfio_container_fd;
+}

You should move this function definition to a separate patch and put it earlier
in the series, as you call this function two patches back.

Thanks for the comment, Neil. I shall move this to a separate patch and put it earlier in the series.

Quoted 10 lines

Also, this gives me pause, as it seems like you're working around the VFIO api.
From what I see, you just use this to get an fd that you can use in an ioctl to
set some DMA settings. First off, theres already a function called pci_vfio_get_container_fd, which does exactly what you are doing here, with
additional safety checking.

Quoted 10 lines

However, even though there is an existing function to do what you want, I would
recommend that you not use it for your purposes. Whenever you expose something
like a file descriptor, you run the risk of multiple accessors racing trying to
set/unset features and preform operations. It would be better if you could add
apropriate api calls to vfio interface to set what you want. That way the library can add appropriate locking if/when needed

I see that vfio_cfg.vfio_container_fd is obtained and stored in pci_vfio_enable(), and this is not modified later.
ENIC PMD needs it to add the IOMMU mapping for buffers used for communicating with adapter firmware. That¹s just adding an entry, and container fd is just passed as an argument. So the following addition in eal_pci_vfio.c should be sufficient. Since vfio_cfg is per process, I do not think that any other checking is required.

int
pci_vfio_map_dma(struct vfio_iommu_type1_dma_map *dma_map)

Quoted 8 lines
{
	return ioctl(vfio_cfg.vfio_container_fd, VFIO_IOMMU_MAP_DMA, dma_map);
}

Does this look alright? Do you think that I¹ve missed out anything here?

It looks better yes, but I'm still confused as to why its necessecary. Looking back at your use of the fd, you're adding an iov entry for a buffer allocated via rte_memzone_reserve, which should come out of the dpdk's configured memory. In pci_vfio_setup_dma_maps, which is part of the pci probe path in eal library, all of the DPDK's physically available memory is already mapped into the iommu in a 1:1 fashion. So why do you need to do this again?

Neil

A message that is not in the archive (sent off-list or not yet received): 20141124113315.GA6038-B26myB8xz7F8NnZeBjwnZQMhkBWG/[email protected]

#15 lore raw

Re: [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

Quoted 118 lines · Neil Horman
Quoted 108 lines · Sujith Sankar (ssujith)
Quoted 50 lines · Neil Horman
Quoted 49 lines · Sujith Sankar
---
 config/common_linuxapp                             | 5 +++++
 lib/Makefile                                       | 1 +
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c         | 7 +++++++
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h | 1 +
 mk/rte.app.mk                                      | 4 ++++
 5 files changed, 18 insertions(+)
config/common_linuxapp +5 -0
index 57b61c9..3c091e7 100644
@@ -210,6 +210,11 @@ CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=4
 CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
 
 #
+# Compile burst-oriented Cisco ENIC PMD driver
+#
+CONFIG_RTE_LIBRTE_ENIC_PMD=y
+
+#
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
lib/Makefile +1 -0
index e3237ff..1911790 100644
@@ -43,6 +43,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
 DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
+DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_enic
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -0
index c776ddc..6bf8f2e 100644
@@ -736,6 +736,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 		maps[i].offset = reg.offset;
 		maps[i].size = reg.size;
 		dev->mem_resource[i].addr = bar_addr;
+		dev->mem_resource[i].len = reg.size;
 	}
 
Quoted 14 lines

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c pci_vfio_is_enabled(void) · line 800

Quoted 11 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +6 -0
 	/* if secondary process, do not set up interrupts */
@@ -791,4 +792,10 @@ pci_vfio_is_enabled(void)
 {
 	return vfio_cfg.vfio_enabled;
 }
+
+int
+pci_vfio_container_fd(void)
+{
+	return vfio_cfg.vfio_container_fd;
+}

You should move this function definition to a separate patch and put it earlier
in the series, as you call this function two patches back.

Thanks for the comment, Neil. I shall move this to a separate patch and put it earlier in the series.

Quoted 11 lines

Also, this gives me pause, as it seems like you're working around the VFIO api.
From what I see, you just use this to get an fd that you can use in an ioctl to
set some DMA settings. First off, theres already a function called pci_vfio_get_container_fd, which does exactly what you are doing here, with
additional safety checking.

However, even though there is an existing function to do what you

want, I

Quoted 8 lines

would
recommend that you not use it for your purposes. Whenever you expose something
like a file descriptor, you run the risk of multiple accessors racing trying to
set/unset features and preform operations. It would be better if you could add
apropriate api calls to vfio interface to set what you want. That way

the

Quoted 1 line

library can add appropriate locking if/when needed

I see that vfio_cfg.vfio_container_fd is obtained and stored in pci_vfio_enable(), and this is not modified later.
ENIC PMD needs it to add the IOMMU mapping for buffers used for communicating with adapter firmware. That¹s just adding an entry, and container fd is just passed as an argument. So the following addition in
eal_pci_vfio.c should be sufficient. Since vfio_cfg is per process, I do
not think that any other checking is required.

int
pci_vfio_map_dma(struct vfio_iommu_type1_dma_map *dma_map)

Quoted 9 lines
{
	return ioctl(vfio_cfg.vfio_container_fd, VFIO_IOMMU_MAP_DMA, dma_map);
}

Does this look alright? Do you think that I¹ve missed out anything here?

Quoted 11 lines

It looks better yes, but I'm still confused as to why its necessecary. Looking
back at your use of the fd, you're adding an iov entry for a buffer allocated
via rte_memzone_reserve, which should come out of the dpdk's configured memory.
In pci_vfio_setup_dma_maps, which is part of the pci probe path in eal library,
all of the DPDK's physically available memory is already mapped into the iommu
in a 1:1 fashion. So why do you need to do this again?

Yes, ideally all the memory allocated using rte_memzone_reserve_aligned() should have its mapping already there in IOMMU. The code that adds the mapping was not there initially, but while testing, I saw that it was giving DMAR errors (like what’s shown below). Putting it back solved the problem.

[295042.852620] DMAR:[fault reason 05] PTE Write access is not set
[295044.406282] dmar: DRHD: handling fault status reg 602
[295044.467981] dmar: DMAR:[DMA Write] Request device [86:00.0] fault addr

7fbd73b32000

Regards,
-Sujith

Quoted 3 lines

Neil

A message that is not in the archive (sent off-list or not yet received): D099544C.28847%[email protected]

#17 lore raw

Re: [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

Quoted 141 lines · Sujith Sankar (ssujith)
Quoted 118 lines · Neil Horman
Quoted 108 lines · Sujith Sankar (ssujith)
Quoted 50 lines · Neil Horman
Quoted 49 lines · Sujith Sankar
---
 config/common_linuxapp                             | 5 +++++
 lib/Makefile                                       | 1 +
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c         | 7 +++++++
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h | 1 +
 mk/rte.app.mk                                      | 4 ++++
 5 files changed, 18 insertions(+)
config/common_linuxapp +5 -0
index 57b61c9..3c091e7 100644
@@ -210,6 +210,11 @@ CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=4
 CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
 
 #
+# Compile burst-oriented Cisco ENIC PMD driver
+#
+CONFIG_RTE_LIBRTE_ENIC_PMD=y
+
+#
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
lib/Makefile +1 -0
index e3237ff..1911790 100644
@@ -43,6 +43,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
 DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
+DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_enic
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -0
index c776ddc..6bf8f2e 100644
@@ -736,6 +736,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
 		maps[i].offset = reg.offset;
 		maps[i].size = reg.size;
 		dev->mem_resource[i].addr = bar_addr;
+		dev->mem_resource[i].len = reg.size;
 	}
 
Quoted 14 lines

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c pci_vfio_is_enabled(void) · line 800

Quoted 11 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +6 -0
 	/* if secondary process, do not set up interrupts */
@@ -791,4 +792,10 @@ pci_vfio_is_enabled(void)
 {
 	return vfio_cfg.vfio_enabled;
 }
+
+int
+pci_vfio_container_fd(void)
+{
+	return vfio_cfg.vfio_container_fd;
+}

You should move this function definition to a separate patch and put it earlier
in the series, as you call this function two patches back.

Thanks for the comment, Neil. I shall move this to a separate patch and put it earlier in the series.

Quoted 11 lines

Also, this gives me pause, as it seems like you're working around the VFIO api.
From what I see, you just use this to get an fd that you can use in an ioctl to
set some DMA settings. First off, theres already a function called pci_vfio_get_container_fd, which does exactly what you are doing here, with
additional safety checking.

However, even though there is an existing function to do what you

want, I

Quoted 8 lines

would
recommend that you not use it for your purposes. Whenever you expose something
like a file descriptor, you run the risk of multiple accessors racing trying to
set/unset features and preform operations. It would be better if you could add
apropriate api calls to vfio interface to set what you want. That way

the

Quoted 1 line

library can add appropriate locking if/when needed

I see that vfio_cfg.vfio_container_fd is obtained and stored in pci_vfio_enable(), and this is not modified later.
ENIC PMD needs it to add the IOMMU mapping for buffers used for communicating with adapter firmware. That¹s just adding an entry, and container fd is just passed as an argument. So the following addition in
eal_pci_vfio.c should be sufficient. Since vfio_cfg is per process, I do
not think that any other checking is required.

int
pci_vfio_map_dma(struct vfio_iommu_type1_dma_map *dma_map)

Quoted 9 lines
{
	return ioctl(vfio_cfg.vfio_container_fd, VFIO_IOMMU_MAP_DMA, dma_map);
}

Does this look alright? Do you think that I¹ve missed out anything here?

Quoted 11 lines

It looks better yes, but I'm still confused as to why its necessecary. Looking
back at your use of the fd, you're adding an iov entry for a buffer allocated
via rte_memzone_reserve, which should come out of the dpdk's configured memory.
In pci_vfio_setup_dma_maps, which is part of the pci probe path in eal library,
all of the DPDK's physically available memory is already mapped into the iommu
in a 1:1 fashion. So why do you need to do this again?

Yes, ideally all the memory allocated using rte_memzone_reserve_aligned() should have its mapping already there in IOMMU. The code that adds the mapping was not there initially, but while testing, I saw that it was giving DMAR errors (like what’s shown below). Putting it back solved the problem.

Quoted 5 lines
[295042.852620] DMAR:[fault reason 05] PTE Write access is not set
[295044.406282] dmar: DRHD: handling fault status reg 602
[295044.467981] dmar: DMAR:[DMA Write] Request device [86:00.0] fault addr

7fbd73b32000

Ok, so what I hear you saying is that, now that that mapping code is available in the pci probe path, you can remove your workaround correct?

Neil

Quoted 8 lines

Regards,
-Sujith

Quoted 3 lines

Neil

A message that is not in the archive (sent off-list or not yet received): 20141124171942.GC7532-B26myB8xz7F8NnZeBjwnZQMhkBWG/[email protected]

#19 lore raw

Re: [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

Quoted 167 lines · Neil Horman
Quoted 160 lines · Sujith Sankar (ssujith)
Quoted 1 line · Neil Horman

On Mon, Nov 24, 2014 at 05:45:54AM +0000, Sujith Sankar (ssujith)

Quoted 21 lines · wrote:
Quoted 21 lines · Neil Horman
Quoted 18 lines · Sujith Sankar
Quoted 16 lines
---
 config/common_linuxapp                             | 5 +++++
 lib/Makefile                                       | 1 +
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c         | 7 +++++++
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h | 1 +
 mk/rte.app.mk                                      | 4 ++++
 5 files changed, 18 insertions(+)
config/common_linuxapp +0 -0
index 57b61c9..3c091e7 100644
@@ -210,6 +210,11 @@ CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=4
 CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
 
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
config/common_linuxapp +5 -0
 #
+# Compile burst-oriented Cisco ENIC PMD driver
+#
+CONFIG_RTE_LIBRTE_ENIC_PMD=y
+
+#
Quoted 8 lines
Quoted 8 lines

lib/Makefile DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) +=

Quoted 8 lines
config/common_linuxapp +0 -0
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
lib/Makefile +0 -0
index e3237ff..1911790 100644
@@ -43,6 +43,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) +=

librte_cmdline

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
lib/Makefile +1 -0
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
 DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
+DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_enic
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c pci_vfio_map_resource(struct rte_pci_device

Quoted 8 lines
lib/Makefile +0 -0
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +0 -0
index c776ddc..6bf8f2e 100644
@@ -736,6 +736,7 @@ pci_vfio_map_resource(struct rte_pci_device

*dev)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -0
 		maps[i].offset = reg.offset;
 		maps[i].size = reg.size;
 		dev->mem_resource[i].addr = bar_addr;
+		dev->mem_resource[i].len = reg.size;
 	}
 
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +0 -0
 	/* if secondary process, do not set up interrupts */
@@ -791,4 +792,10 @@ pci_vfio_is_enabled(void)
 {
 	return vfio_cfg.vfio_enabled;
Quoted 8 lines
Quoted 8 lines

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c pci_vfio_is_enabled(void) · line 800

Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +6 -0
 }
+
+int
+pci_vfio_container_fd(void)
+{
+	return vfio_cfg.vfio_container_fd;
+}

You should move this function definition to a separate patch and

put it

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

earlier
in the series, as you call this function two patches back.

Thanks for the comment, Neil. I shall move this to a separate patch

and

Quoted 4 lines
Quoted 4 lines

put it earlier in the series.

Quoted 2 lines

Also, this gives me pause, as it seems like you're working around

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

VFIO api.
From what I see, you just use this to get an fd that you can use in

an

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

ioctl to
set some DMA settings. First off, theres already a function called pci_vfio_get_container_fd, which does exactly what you are doing

here,

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

with
additional safety checking.

However, even though there is an existing function to do what you

want, I

Quoted 2 lines

would
recommend that you not use it for your purposes. Whenever you

expose

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

something
like a file descriptor, you run the risk of multiple accessors

racing

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

trying to
set/unset features and preform operations. It would be better if

you

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

could add
apropriate api calls to vfio interface to set what you want. That

way

Quoted 8 lines
Quoted 8 lines

the

Quoted 1 line

library can add appropriate locking if/when needed

I see that vfio_cfg.vfio_container_fd is obtained and stored in pci_vfio_enable(), and this is not modified later.
ENIC PMD needs it to add the IOMMU mapping for buffers used for communicating with adapter firmware. That¹s just adding an entry,

and

Quoted 1 line
Quoted 1 line

container fd is just passed as an argument. So the following

addition

Quoted 2 lines
Quoted 2 lines

in
eal_pci_vfio.c should be sufficient. Since vfio_cfg is per process,

I

Quoted 7 lines
Quoted 7 lines

do
not think that any other checking is required.

int
pci_vfio_map_dma(struct vfio_iommu_type1_dma_map *dma_map) {
return ioctl(vfio_cfg.vfio_container_fd, VFIO_IOMMU_MAP_DMA,

dma_map);

Quoted 7 lines
Quoted 7 lines

}

Does this look alright? Do you think that I¹ve missed out anything here?

Quoted 9 lines

It looks better yes, but I'm still confused as to why its necessecary. Looking
back at your use of the fd, you're adding an iov entry for a buffer allocated
via rte_memzone_reserve, which should come out of the dpdk's configured memory.
In pci_vfio_setup_dma_maps, which is part of the pci probe path in eal library,
all of the DPDK's physically available memory is already mapped into

the

Quoted 2 lines

iommu
in a 1:1 fashion. So why do you need to do this again?

Yes, ideally all the memory allocated using rte_memzone_reserve_aligned()
should have its mapping already there in IOMMU. The code that adds the mapping was not there initially, but while testing, I saw that it was giving DMAR errors (like what’s shown below). Putting it back solved the
problem.

Quoted 6 lines
[295042.852620] DMAR:[fault reason 05] PTE Write access is not set
[295044.406282] dmar: DRHD: handling fault status reg 602
[295044.467981] dmar: DMAR:[DMA Write] Request device [86:00.0] fault

addr
7fbd73b32000

Quoted 3 lines

Ok, so what I hear you saying is that, now that that mapping code is available
in the pci probe path, you can remove your workaround correct?

Comparing the two mapping functions, I could find out a difference. ENIC PMD is using virtual address of the buffers to fill dma_map->iova, while the lib is filling in the phys_addr. Both the cases work. I’ve modified ENIC PMD to use phys_addr and the initial tests went through fine. Let me spend some more time testing it. After that I shall get back with V4.

Thank you Neil !

-Sujith

Quoted 11 lines

Neil

Quoted 8 lines

Regards,
-Sujith

Quoted 3 lines

Neil

A message that is not in the archive (sent off-list or not yet received): D09A193B.28971%[email protected]

#21 lore raw

Re: [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

Quoted 175 lines · Sujith Sankar (ssujith)
Quoted 167 lines · Neil Horman
Quoted 160 lines · Sujith Sankar (ssujith)
Quoted 1 line · Neil Horman

On Mon, Nov 24, 2014 at 05:45:54AM +0000, Sujith Sankar (ssujith)

Quoted 21 lines · wrote:
Quoted 21 lines · Neil Horman
Quoted 18 lines · Sujith Sankar
Quoted 16 lines
---
 config/common_linuxapp                             | 5 +++++
 lib/Makefile                                       | 1 +
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c         | 7 +++++++
 lib/librte_eal/linuxapp/eal/include/eal_pci_init.h | 1 +
 mk/rte.app.mk                                      | 4 ++++
 5 files changed, 18 insertions(+)
config/common_linuxapp +0 -0
index 57b61c9..3c091e7 100644
@@ -210,6 +210,11 @@ CONFIG_RTE_LIBRTE_I40E_QUEUE_NUM_PER_VM=4
 CONFIG_RTE_LIBRTE_I40E_ITR_INTERVAL=-1
 
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
config/common_linuxapp +5 -0
 #
+# Compile burst-oriented Cisco ENIC PMD driver
+#
+CONFIG_RTE_LIBRTE_ENIC_PMD=y
+
+#
Quoted 8 lines
Quoted 8 lines

lib/Makefile DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) +=

Quoted 8 lines
config/common_linuxapp +0 -0
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
lib/Makefile +0 -0
index e3237ff..1911790 100644
@@ -43,6 +43,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) +=

librte_cmdline

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
lib/Makefile +1 -0
 DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether
 DIRS-$(CONFIG_RTE_LIBRTE_E1000_PMD) += librte_pmd_e1000
 DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_ixgbe
+DIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += librte_pmd_enic
 DIRS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += librte_pmd_i40e
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c pci_vfio_map_resource(struct rte_pci_device

Quoted 8 lines
lib/Makefile +0 -0
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += librte_pmd_bond
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += librte_pmd_ring
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +0 -0
index c776ddc..6bf8f2e 100644
@@ -736,6 +736,7 @@ pci_vfio_map_resource(struct rte_pci_device

*dev)

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -0
 		maps[i].offset = reg.offset;
 		maps[i].size = reg.size;
 		dev->mem_resource[i].addr = bar_addr;
+		dev->mem_resource[i].len = reg.size;
 	}
 
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +0 -0
 	/* if secondary process, do not set up interrupts */
@@ -791,4 +792,10 @@ pci_vfio_is_enabled(void)
 {
 	return vfio_cfg.vfio_enabled;
Quoted 8 lines
Quoted 8 lines

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c pci_vfio_is_enabled(void) · line 800

Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +6 -0
 }
+
+int
+pci_vfio_container_fd(void)
+{
+	return vfio_cfg.vfio_container_fd;
+}

You should move this function definition to a separate patch and

put it

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

earlier
in the series, as you call this function two patches back.

Thanks for the comment, Neil. I shall move this to a separate patch

and

Quoted 4 lines
Quoted 4 lines

put it earlier in the series.

Quoted 2 lines

Also, this gives me pause, as it seems like you're working around

the

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

VFIO api.
From what I see, you just use this to get an fd that you can use in

an

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

ioctl to
set some DMA settings. First off, theres already a function called pci_vfio_get_container_fd, which does exactly what you are doing

here,

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

with
additional safety checking.

However, even though there is an existing function to do what you

want, I

Quoted 2 lines

would
recommend that you not use it for your purposes. Whenever you

expose

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

something
like a file descriptor, you run the risk of multiple accessors

racing

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

trying to
set/unset features and preform operations. It would be better if

you

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

could add
apropriate api calls to vfio interface to set what you want. That

way

Quoted 8 lines
Quoted 8 lines

the

Quoted 1 line

library can add appropriate locking if/when needed

I see that vfio_cfg.vfio_container_fd is obtained and stored in pci_vfio_enable(), and this is not modified later.
ENIC PMD needs it to add the IOMMU mapping for buffers used for communicating with adapter firmware. That¹s just adding an entry,

and

Quoted 1 line
Quoted 1 line

container fd is just passed as an argument. So the following

addition

Quoted 2 lines
Quoted 2 lines

in
eal_pci_vfio.c should be sufficient. Since vfio_cfg is per process,

I

Quoted 7 lines
Quoted 7 lines

do
not think that any other checking is required.

int
pci_vfio_map_dma(struct vfio_iommu_type1_dma_map *dma_map) {
return ioctl(vfio_cfg.vfio_container_fd, VFIO_IOMMU_MAP_DMA,

dma_map);

Quoted 7 lines
Quoted 7 lines

}

Does this look alright? Do you think that I¹ve missed out anything here?

Quoted 9 lines

It looks better yes, but I'm still confused as to why its necessecary. Looking
back at your use of the fd, you're adding an iov entry for a buffer allocated
via rte_memzone_reserve, which should come out of the dpdk's configured memory.
In pci_vfio_setup_dma_maps, which is part of the pci probe path in eal library,
all of the DPDK's physically available memory is already mapped into

the

Quoted 2 lines

iommu
in a 1:1 fashion. So why do you need to do this again?

Yes, ideally all the memory allocated using rte_memzone_reserve_aligned()
should have its mapping already there in IOMMU. The code that adds the mapping was not there initially, but while testing, I saw that it was giving DMAR errors (like what’s shown below). Putting it back solved the
problem.

Quoted 6 lines
[295042.852620] DMAR:[fault reason 05] PTE Write access is not set
[295044.406282] dmar: DRHD: handling fault status reg 602
[295044.467981] dmar: DMAR:[DMA Write] Request device [86:00.0] fault

addr
7fbd73b32000

Quoted 3 lines

Ok, so what I hear you saying is that, now that that mapping code is available
in the pci probe path, you can remove your workaround correct?

Quoted 9 lines

Comparing the two mapping functions, I could find out a difference. ENIC PMD is using virtual address of the buffers to fill dma_map->iova, while the lib is filling in the phys_addr. Both the cases work. I’ve modified ENIC PMD to use phys_addr and the initial tests went through fine. Let me spend some more time testing it. After that I shall get back with V4.

Thank you Neil !

Thank you!
neil

Quoted 1 line
#22 lore raw

Re: [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

In reply to a message not in the archive

Hello Sujith,

Quoted 7 lines · Sujith Sankar
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +0 -0
index c776ddc..6bf8f2e 100644

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c pci_vfio_map_resource(struct rte_pci_device *dev) · line 742

Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -0
@@ -736,6 +736,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
                maps[i].offset = reg.offset;
                maps[i].size = reg.size;
                dev->mem_resource[i].addr = bar_addr;
+               dev->mem_resource[i].len = reg.size;
        }
 
        /* if secondary process, do not set up interrupts */

Not sure I understand why you need to overwrite the length value. This is supposed to be initialised before by "generic" code. This looks like a hack or a workaround.

Can you elaborate on this change ?
Thanks.

Signature · 1 line
David Marchand

A message that is not in the archive (sent off-list or not yet received): CALwxeUsQ4=jW-OB_AqXVHL8Rx7sAJt+qn8yTYDuW9j-r=e+afw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#24 lore raw

Re: [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

Hi David,

During the testing, I saw that the length field was 0. ENIC PMD validates the length of the BAR against a max value. In order to get the length in the resource structure, I added this statement.

Thanks,
-Sujith

From: David Marchand <[email protected]<mailto:[email protected]>>
Date: Monday, 24 November 2014 4:33 pm
To: "Sujith Sankar (ssujith)" <[email protected]<mailto:[email protected]>>
Cc: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>, "Prasad Rao (prrao)" <[email protected]<mailto:[email protected]>>
Subject: Re: [dpdk-dev] [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

Hello Sujith,

On Sun, Nov 23, 2014 at 5:08 PM, Sujith Sankar <[email protected]<mailto:[email protected]>> wrote:

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -0
index c776ddc..6bf8f2e 100644
@@ -736,6 +736,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
                maps[i].offset = reg.offset;
                maps[i].size = reg.size;
                dev->mem_resource[i].addr = bar_addr;
+               dev->mem_resource[i].len = reg.size;
        }
 
        /* if secondary process, do not set up interrupts */

Not sure I understand why you need to overwrite the length value. This is supposed to be initialised before by "generic" code. This looks like a hack or a workaround.

Can you elaborate on this change ?
Thanks.

--
David Marchand

A message that is not in the archive (sent off-list or not yet received): D0995111.28833%[email protected]

#26 lore raw

Re: [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

Mmm, I am not that familiar with vfio code, but I would say that there is something buggy in pci_vfio_map_resource() when compared
to pci_uio_map_resource().
Is not there a problem with finding the right index of dev->mem_resource[] array ?

Signature · 4 lines
David Marchand


On Mon, Nov 24, 2014 at 4:51 PM, Sujith Sankar (ssujith) <[email protected]>
Quoted 48 lines · wrote:

Hi David,

During the testing, I saw that the length field was 0. ENIC PMD
validates the length of the BAR against a max value.
In order to get the length in the resource structure, I added this statement.

Thanks,
-Sujith

From: David Marchand <[email protected]>
Date: Monday, 24 November 2014 4:33 pm
To: "Sujith Sankar (ssujith)" <[email protected]>
Cc: "[email protected]" <[email protected]>, "Prasad Rao (prrao)" <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v3 6/6] DPDK changes for accommodating
ENIC PMD

Hello Sujith,

Quoted 7 lines · Sujith Sankar
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +0 -0
index c776ddc..6bf8f2e 100644

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c pci_vfio_map_resource(struct rte_pci_device *dev) · line 742

Quoted 7 lines
lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -0
@@ -736,6 +736,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
                maps[i].offset = reg.offset;
                maps[i].size = reg.size;
                dev->mem_resource[i].addr = bar_addr;
+               dev->mem_resource[i].len = reg.size;
        }
 
        /* if secondary process, do not set up interrupts */

Not sure I understand why you need to overwrite the length value.
This is supposed to be initialised before by "generic" code. This looks like a hack or a workaround.

Can you elaborate on this change ?
Thanks.

--
David Marchand

A message that is not in the archive (sent off-list or not yet received): CALwxeUuSf4GsQVmLmfVJPqCjFJMOofU09QUcY9DMJPvHorA9YA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#28 lore raw

Re: [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

David,

ENIC PMD needs info about BAR0 only, and vfio map routine puts it at index 0. So, it didn’t pose trouble.

Regards,
-Sujith

From: David Marchand <[email protected]<mailto:[email protected]>>
Date: Monday, 24 November 2014 9:45 pm
To: "Sujith Sankar (ssujith)" <[email protected]<mailto:[email protected]>>
Cc: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>, "Prasad Rao (prrao)" <[email protected]<mailto:[email protected]>>
Subject: Re: [dpdk-dev] [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

Mmm, I am not that familiar with vfio code, but I would say that there is something buggy in pci_vfio_map_resource() when compared to pci_uio_map_resource(). Is not there a problem with finding the right index of dev->mem_resource[] array ?

--
David Marchand

On Mon, Nov 24, 2014 at 4:51 PM, Sujith Sankar (ssujith) <[email protected]<mailto:[email protected]>> wrote:
Hi David,

During the testing, I saw that the length field was 0. ENIC PMD validates the length of the BAR against a max value. In order to get the length in the resource structure, I added this statement.

Thanks,
-Sujith

From: David Marchand <[email protected]<mailto:[email protected]>>
Date: Monday, 24 November 2014 4:33 pm
To: "Sujith Sankar (ssujith)" <[email protected]<mailto:[email protected]>>
Cc: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>>, "Prasad Rao (prrao)" <[email protected]<mailto:[email protected]>>
Subject: Re: [dpdk-dev] [PATCH v3 6/6] DPDK changes for accommodating ENIC PMD

Hello Sujith,

On Sun, Nov 23, 2014 at 5:08 PM, Sujith Sankar <[email protected]<mailto:[email protected]>> wrote:

lib/librte_eal/linuxapp/eal/eal_pci_vfio.c +1 -0
index c776ddc..6bf8f2e 100644
@@ -736,6 +736,7 @@ pci_vfio_map_resource(struct rte_pci_device *dev)
                maps[i].offset = reg.offset;
                maps[i].size = reg.size;
                dev->mem_resource[i].addr = bar_addr;
+               dev->mem_resource[i].len = reg.size;
        }
 
        /* if secondary process, do not set up interrupts */

Not sure I understand why you need to overwrite the length value. This is supposed to be initialised before by "generic" code. This looks like a hack or a workaround.

Can you elaborate on this change ?
Thanks.

--
David Marchand