[dpdk-dev] [PATCH v5 00/25] DPDK PMD for ThunderX NIC device

2016-06-15 Thread Jerin Jacob
This patch set provides the initial version of DPDK PMD for the
built-in NIC device in Cavium ThunderX SoC family.

Implemented features and ThunderX nicvf PMD documentation added
in doc/guides/nics/overview.rst and doc/guides/nics/thunderx.rst
respectively in this patch set.

These patches are checked using checkpatch.sh with following
additional ignore option:
options="$options --ignore=CAMELCASE,BRACKET_SPACE"
CAMELCASE - To accommodate PRIx64
BRACKET_SPACE - To accommodate AT inline line assembly in two places

This patch set is based on DPDK 16.07-RC1
and tested with git HEAD change-set
ca173a909538a2f1082cd0dcb4d778a97dab69c3 along with
following depended patch

http://dpdk.org/dev/patchwork/patch/11826/
ethdev: add tunnel and port RSS offload types

V1->V2

http://dpdk.org/dev/patchwork/patch/12609/
-- added const for the const struct tables
-- remove multiple blank lines
-- addressed style comments
http://dpdk.org/dev/patchwork/patch/12610/
-- removed DEPDIRS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += lib/librte_net 
lib/librte_malloc
-- add const for table structs
-- addressed style comments
http://dpdk.org/dev/patchwork/patch/12614/
-- s/DEFAULT_*/NICVF_DEFAULT_*/gc
http://dpdk.org/dev/patchwork/patch/12615/
-- Fix typos
-- addressed style comments
http://dpdk.org/dev/patchwork/patch/12616/
-- removed redundant txq->tail = 0 and txq->head = 0
http://dpdk.org/dev/patchwork/patch/12627/
-- fixed the documentation changes

-- fixed TAB+space occurrences in functions
-- rebased to c8c33ad7f94c59d1c0676af0cfd61207b3e808db

V2->V3

http://dpdk.org/dev/patchwork/patch/13060/
-- Changed polling infrastructure to use rte_eal_alarm* instead of 
timerfd_create API
-- rebased to ca173a909538a2f1082cd0dcb4d778a97dab69c3

V3->V4

addressed review comments of Ferruh's review

http://dpdk.org/dev/patchwork/patch/13314/
-- s/avilable/available
http://dpdk.org/dev/patchwork/patch/13323/
-- s/witout/without

http://dpdk.org/dev/patchwork/patch/13318/
-- s/nicvf_free_xmittted_buffers/nicvf_free_xmitted_buffers
-- fix checkpatch errors
http://dpdk.org/dev/patchwork/patch/13307/
-- addressed review comments
http://dpdk.org/dev/patchwork/patch/13308/
-- addressed review comments
http://dpdk.org/dev/patchwork/patch/13320/
-- addressed review comments
http://dpdk.org/dev/patchwork/patch/13321/
-- addressed review comments
http://dpdk.org/dev/patchwork/patch/13322/
-- addressed review comments
http://dpdk.org/dev/patchwork/patch/13324/
-- addressed review comments and created separated patch for
platform specific config change

-- update change log to net/thunderx: 

V4->V5
-- splitting up drivers/net/thunderx/nicvf/base files to following
patches as suggested by Bruce

net/thunderx/base: add HW constants for ThunderX inbuilt NIC
net/thunderx/base: add register definition for ThunderX inbuilt NIC
net/thunderx/base: implement DPDK based platform abstraction for base code
net/thunderx/base: add mbox API for ThunderX PF/VF driver communication
net/thunderx/base: add hardware API for ThunderX nicvf inbuilt NIC
net/thunderx/base: add RSS and reta configuration HW APIs
net/thunderx/base: add statistics get HW APIs

-- Corrected wrong git commit log messages flagged by check-git-log.sh

Jerin Jacob (25):
  net/thunderx/base: add HW constants for ThunderX inbuilt NIC
  net/thunderx/base: add register definition for ThunderX inbuilt NIC
  net/thunderx/base: implement DPDK based platform abstraction for base
code
  net/thunderx/base: add mbox API for ThunderX PF/VF driver
communication
  net/thunderx/base: add hardware API for ThunderX nicvf inbuilt NIC
  net/thunderx/base: add RSS and reta configuration HW APIs
  net/thunderx/base: add statistics get HW APIs
  net/thunderx: add pmd skeleton
  net/thunderx: add link status and link update support
  net/thunderx: add registers dump support
  net/thunderx: add ethdev configure support
  net/thunderx: add get device info support
  net/thunderx: add Rx queue setup and release support
  net/thunderx: add Tx queue setup and release support
  net/thunderx: add RSS and reta query and update support
  net/thunderx: add MTU set and promiscuous enable support
  net/thunderx: add stats support
  net/thunderx: add single and multi segment Tx functions
  net/thunderx: add single and multi segment Rx functions
  net/thunderx: implement supported ptype get and Rx queue count
  net/thunderx: add Rx queue start and stop support
  net/thunderx: add Tx queue start and stop support
  net/thunderx: add device start,stop and close support
  net/thunderx: updated driver documentation and release notes
  maintainers: claim responsibility for the ThunderX nicvf PMD

 MAINTAINERS|6 +
 config/common_base |   10 +
 config/defconfig_arm64-thunderx-linuxapp-gcc   |   10 +
 doc/guides/nics/index.rst  |1 +
 doc/guides/nics/overview.rst   |   96 +-
 

[dpdk-dev] [PATCH v5 01/25] net/thunderx/base: add HW constants for ThunderX inbuilt NIC

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/base/nicvf_hw_defs.h | 551 ++
 1 file changed, 551 insertions(+)
 create mode 100644 drivers/net/thunderx/base/nicvf_hw_defs.h

diff --git a/drivers/net/thunderx/base/nicvf_hw_defs.h 
b/drivers/net/thunderx/base/nicvf_hw_defs.h
new file mode 100644
index 000..8a58f03
--- /dev/null
+++ b/drivers/net/thunderx/base/nicvf_hw_defs.h
@@ -0,0 +1,551 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright (C) Cavium networks Ltd. 2016.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Cavium networks nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   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
+ *   OWNER 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.
+ */
+
+#ifndef _THUNDERX_NICVF_HW_DEFS_H
+#define _THUNDERX_NICVF_HW_DEFS_H
+
+#include 
+#include 
+
+/* Virtual function register offsets */
+
+#define NIC_VF_CFG  (0x20)
+#define NIC_VF_PF_MAILBOX_0_1   (0x000130)
+#define NIC_VF_INT  (0x000200)
+#define NIC_VF_INT_W1S  (0x000220)
+#define NIC_VF_ENA_W1C  (0x000240)
+#define NIC_VF_ENA_W1S  (0x000260)
+
+#define NIC_VNIC_RSS_CFG(0x0020E0)
+#define NIC_VNIC_RSS_KEY_0_4(0x002200)
+#define NIC_VNIC_TX_STAT_0_4(0x004000)
+#define NIC_VNIC_RX_STAT_0_13   (0x004100)
+#define NIC_VNIC_RQ_GEN_CFG (0x010010)
+
+#define NIC_QSET_CQ_0_7_CFG (0x010400)
+#define NIC_QSET_CQ_0_7_CFG2(0x010408)
+#define NIC_QSET_CQ_0_7_THRESH  (0x010410)
+#define NIC_QSET_CQ_0_7_BASE(0x010420)
+#define NIC_QSET_CQ_0_7_HEAD(0x010428)
+#define NIC_QSET_CQ_0_7_TAIL(0x010430)
+#define NIC_QSET_CQ_0_7_DOOR(0x010438)
+#define NIC_QSET_CQ_0_7_STATUS  (0x010440)
+#define NIC_QSET_CQ_0_7_STATUS2 (0x010448)
+#define NIC_QSET_CQ_0_7_DEBUG   (0x010450)
+
+#define NIC_QSET_RQ_0_7_CFG (0x010600)
+#define NIC_QSET_RQ_0_7_STATUS0 (0x010700)
+#define NIC_QSET_RQ_0_7_STATUS1 (0x010708)
+
+#define NIC_QSET_SQ_0_7_CFG (0x010800)
+#define NIC_QSET_SQ_0_7_THRESH  (0x010810)
+#define NIC_QSET_SQ_0_7_BASE(0x010820)
+#define NIC_QSET_SQ_0_7_HEAD(0x010828)
+#define NIC_QSET_SQ_0_7_TAIL(0x010830)
+#define NIC_QSET_SQ_0_7_DOOR(0x010838)
+#define NIC_QSET_SQ_0_7_STATUS  (0x010840)
+#define NIC_QSET_SQ_0_7_DEBUG   (0x010848)
+#define NIC_QSET_SQ_0_7_STATUS0 (0x010900)
+#define NIC_QSET_SQ_0_7_STATUS1 (0x010908)
+
+#define NIC_QSET_RBDR_0_1_CFG   (0x010C00)
+#define NIC_QSET_RBDR_0_1_THRESH(0x010C10)
+#define NIC_QSET_RBDR_0_1_BASE  (0x010C20)
+#define NIC_QSET_RBDR_0_1_HEAD  (0x010C28)
+#define NIC_QSET_RBDR_0_1_TAIL  (0x010C30)
+#define NIC_QSET_RBDR_0_1_DOOR  (0x010C38)
+#define NIC_QSET_RBDR_0_1_STATUS0   (0x010C40)
+#define NIC_QSET_RBDR_0_1_STATUS1   (0x010C48)
+#define NIC_QSET_RBDR_0_1_PRFCH_STATUS  (0x010C50)
+
+/* vNIC HW Constants */
+
+#define NIC_Q_NUM_SHIFT 18
+
+#define MAX_QUEUE_SET   128
+#define MAX_RCV_QUEUES_PER_QS   8
+#define MAX_RCV_BUF_DESC_RINGS_PER_QS   2
+#define MAX_SND_QUEUES_PER_QS   8
+#define MAX_CMP_QUEUES_PER_QS   8
+
+#define NICVF_INTR_CQ_SHIFT 0
+#define 

[dpdk-dev] [PATCH v5 02/25] net/thunderx/base: add register definition for ThunderX inbuilt NIC

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/base/nicvf_hw_defs.h | 668 ++
 1 file changed, 668 insertions(+)

diff --git a/drivers/net/thunderx/base/nicvf_hw_defs.h 
b/drivers/net/thunderx/base/nicvf_hw_defs.h
index 8a58f03..88ecd17 100644
--- a/drivers/net/thunderx/base/nicvf_hw_defs.h
+++ b/drivers/net/thunderx/base/nicvf_hw_defs.h
@@ -548,4 +548,672 @@ enum nic_stat_vnic_tx_e {
TX_DROP,
 };

+/* vNIC HW Register structures */
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint64_t cqe_type:4;
+   uint64_t stdn_fault:1;
+   uint64_t rsvd0:1;
+   uint64_t rq_qs:7;
+   uint64_t rq_idx:3;
+   uint64_t rsvd1:12;
+   uint64_t rss_alg:4;
+   uint64_t rsvd2:4;
+   uint64_t rb_cnt:4;
+   uint64_t vlan_found:1;
+   uint64_t vlan_stripped:1;
+   uint64_t vlan2_found:1;
+   uint64_t vlan2_stripped:1;
+   uint64_t l4_type:4;
+   uint64_t l3_type:4;
+   uint64_t l2_present:1;
+   uint64_t err_level:3;
+   uint64_t err_opcode:8;
+#else
+   uint64_t err_opcode:8;
+   uint64_t err_level:3;
+   uint64_t l2_present:1;
+   uint64_t l3_type:4;
+   uint64_t l4_type:4;
+   uint64_t vlan2_stripped:1;
+   uint64_t vlan2_found:1;
+   uint64_t vlan_stripped:1;
+   uint64_t vlan_found:1;
+   uint64_t rb_cnt:4;
+   uint64_t rsvd2:4;
+   uint64_t rss_alg:4;
+   uint64_t rsvd1:12;
+   uint64_t rq_idx:3;
+   uint64_t rq_qs:7;
+   uint64_t rsvd0:1;
+   uint64_t stdn_fault:1;
+   uint64_t cqe_type:4;
+#endif
+   };
+} cqe_rx_word0_t;
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint64_t pkt_len:16;
+   uint64_t l2_ptr:8;
+   uint64_t l3_ptr:8;
+   uint64_t l4_ptr:8;
+   uint64_t cq_pkt_len:8;
+   uint64_t align_pad:3;
+   uint64_t rsvd3:1;
+   uint64_t chan:12;
+#else
+   uint64_t chan:12;
+   uint64_t rsvd3:1;
+   uint64_t align_pad:3;
+   uint64_t cq_pkt_len:8;
+   uint64_t l4_ptr:8;
+   uint64_t l3_ptr:8;
+   uint64_t l2_ptr:8;
+   uint64_t pkt_len:16;
+#endif
+   };
+} cqe_rx_word1_t;
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint64_t rss_tag:32;
+   uint64_t vlan_tci:16;
+   uint64_t vlan_ptr:8;
+   uint64_t vlan2_ptr:8;
+#else
+   uint64_t vlan2_ptr:8;
+   uint64_t vlan_ptr:8;
+   uint64_t vlan_tci:16;
+   uint64_t rss_tag:32;
+#endif
+   };
+} cqe_rx_word2_t;
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint16_t rb3_sz;
+   uint16_t rb2_sz;
+   uint16_t rb1_sz;
+   uint16_t rb0_sz;
+#else
+   uint16_t rb0_sz;
+   uint16_t rb1_sz;
+   uint16_t rb2_sz;
+   uint16_t rb3_sz;
+#endif
+   };
+} cqe_rx_word3_t;
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint16_t rb7_sz;
+   uint16_t rb6_sz;
+   uint16_t rb5_sz;
+   uint16_t rb4_sz;
+#else
+   uint16_t rb4_sz;
+   uint16_t rb5_sz;
+   uint16_t rb6_sz;
+   uint16_t rb7_sz;
+#endif
+   };
+} cqe_rx_word4_t;
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint16_t rb11_sz;
+   uint16_t rb10_sz;
+   uint16_t rb9_sz;
+   uint16_t rb8_sz;
+#else
+   uint16_t rb8_sz;
+   uint16_t rb9_sz;
+   uint16_t rb10_sz;
+   uint16_t rb11_sz;
+#endif
+   };
+} cqe_rx_word5_t;
+
+typedef union {
+   uint64_t u64;
+   struct {
+#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+   uint64_t vlan_found:1;
+   uint64_t vlan_stripped:1;
+   uint64_t vlan2_found:1;
+   uint64_t vlan2_stripped:1;
+   uint64_t rsvd2:3;
+   uint64_t inner_l2:1;
+   uint64_t inner_l4type:4;
+   uint64_t inner_l3type:4;
+   uint64_t vlan_ptr:8;
+ 

[dpdk-dev] [PATCH v5 03/25] net/thunderx/base: implement DPDK based platform abstraction for base code

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/base/nicvf_plat.h | 129 +
 1 file changed, 129 insertions(+)
 create mode 100644 drivers/net/thunderx/base/nicvf_plat.h

diff --git a/drivers/net/thunderx/base/nicvf_plat.h 
b/drivers/net/thunderx/base/nicvf_plat.h
new file mode 100644
index 000..33fef08
--- /dev/null
+++ b/drivers/net/thunderx/base/nicvf_plat.h
@@ -0,0 +1,129 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright (C) Cavium networks Ltd. 2016.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Cavium networks nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   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
+ *   OWNER 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.
+ */
+
+#ifndef _THUNDERX_NICVF_H
+#define _THUNDERX_NICVF_H
+
+/* Platform/OS/arch specific abstractions */
+
+/* log */
+#include 
+#include "../nicvf_logs.h"
+
+#define nicvf_log_error(s, ...) PMD_DRV_LOG(ERR, s, ##__VA_ARGS__)
+
+#define nicvf_log_debug(s, ...) PMD_DRV_LOG(DEBUG, s, ##__VA_ARGS__)
+
+#define nicvf_mbox_log(s, ...) PMD_MBOX_LOG(DEBUG, s, ##__VA_ARGS__)
+
+#define nicvf_log(s, ...) fprintf(stderr, s, ##__VA_ARGS__)
+
+/* delay */
+#include 
+#define nicvf_delay_us(x) rte_delay_us(x)
+
+/* barrier */
+#include 
+#define nicvf_smp_wmb() rte_smp_wmb()
+#define nicvf_smp_rmb() rte_smp_rmb()
+
+/* utils */
+#include 
+#define nicvf_min(x, y) RTE_MIN(x, y)
+
+/* byte order */
+#include 
+#define nicvf_cpu_to_be_64(x) rte_cpu_to_be_64(x)
+#define nicvf_be_to_cpu_64(x) rte_be_to_cpu_64(x)
+
+/* Constants */
+#include 
+#define NICVF_MAC_ADDR_SIZE ETHER_ADDR_LEN
+
+/* ARM64 specific functions */
+#if defined(RTE_ARCH_ARM64)
+#define nicvf_prefetch_store_keep(_ptr) ({\
+   asm volatile("prfm pstl1keep, %a0\n" : : "p" (_ptr)); })
+
+static inline void __attribute__((always_inline))
+nicvf_addr_write(uintptr_t addr, uint64_t val)
+{
+   asm volatile(
+   "str %x[val], [%x[addr]]"
+   :
+   : [val] "r" (val), [addr] "r" (addr));
+}
+
+static inline uint64_t __attribute__((always_inline))
+nicvf_addr_read(uintptr_t addr)
+{
+   uint64_t val;
+
+   asm volatile(
+   "ldr %x[val], [%x[addr]]"
+   : [val] "=r" (val)
+   : [addr] "r" (addr));
+   return val;
+}
+
+#define NICVF_LOAD_PAIR(reg1, reg2, addr) ({   \
+   asm volatile(   \
+   "ldp %x[x1], %x[x0], [%x[p1]]"  \
+   : [x1]"=r"(reg1), [x0]"=r"(reg2)\
+   : [p1]"r"(addr) \
+   ); })
+
+#else /* non optimized functions for building on non arm64 arch */
+
+#define nicvf_prefetch_store_keep(_ptr) do {} while (0)
+
+static inline void __attribute__((always_inline))
+nicvf_addr_write(uintptr_t addr, uint64_t val)
+{
+   *(volatile uint64_t *)addr = val;
+}
+
+static inline uint64_t __attribute__((always_inline))
+nicvf_addr_read(uintptr_t addr)
+{
+   return  *(volatile uint64_t *)addr;
+}
+
+#define NICVF_LOAD_PAIR(reg1, reg2, addr)  \
+do {   \
+   reg1 = nicvf_addr_read((uintptr_t)addr);\
+   reg2 = nicvf_addr_read((uintptr_t)addr + 8);\
+} while (0)
+
+#endif
+
+#endif /* _THUNDERX_NICVF_H */
-- 
2.5.5



[dpdk-dev] [PATCH v5 04/25] net/thunderx/base: add mbox API for ThunderX PF/VF driver communication

2016-06-15 Thread Jerin Jacob
DPDK nicvf driver doesn't have access to NIC's PF address space.
Introduce a mailbox mechanism to communicate with PF driver through
shared 128bit register interface.

Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
---
 drivers/net/thunderx/base/nicvf_mbox.c | 418 +
 drivers/net/thunderx/base/nicvf_mbox.h | 232 ++
 drivers/net/thunderx/base/nicvf_plat.h |   2 +
 3 files changed, 652 insertions(+)
 create mode 100644 drivers/net/thunderx/base/nicvf_mbox.c
 create mode 100644 drivers/net/thunderx/base/nicvf_mbox.h

diff --git a/drivers/net/thunderx/base/nicvf_mbox.c 
b/drivers/net/thunderx/base/nicvf_mbox.c
new file mode 100644
index 000..3067331
--- /dev/null
+++ b/drivers/net/thunderx/base/nicvf_mbox.c
@@ -0,0 +1,418 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright (C) Cavium networks Ltd. 2016.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Cavium networks nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   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
+ *   OWNER 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 
+#include 
+#include 
+#include 
+
+#include "nicvf_plat.h"
+
+#define NICVF_MBOX_PF_RESPONSE_DELAY_US   (1000)
+
+static const char *mbox_message[NIC_MBOX_MSG_MAX] =  {
+   [NIC_MBOX_MSG_INVALID]= "NIC_MBOX_MSG_INVALID",
+   [NIC_MBOX_MSG_READY]  = "NIC_MBOX_MSG_READY",
+   [NIC_MBOX_MSG_ACK]= "NIC_MBOX_MSG_ACK",
+   [NIC_MBOX_MSG_NACK]   = "NIC_MBOX_MSG_ACK",
+   [NIC_MBOX_MSG_QS_CFG] = "NIC_MBOX_MSG_QS_CFG",
+   [NIC_MBOX_MSG_RQ_CFG] = "NIC_MBOX_MSG_RQ_CFG",
+   [NIC_MBOX_MSG_SQ_CFG] = "NIC_MBOX_MSG_SQ_CFG",
+   [NIC_MBOX_MSG_RQ_DROP_CFG]= "NIC_MBOX_MSG_RQ_DROP_CFG",
+   [NIC_MBOX_MSG_SET_MAC]= "NIC_MBOX_MSG_SET_MAC",
+   [NIC_MBOX_MSG_SET_MAX_FRS]= "NIC_MBOX_MSG_SET_MAX_FRS",
+   [NIC_MBOX_MSG_CPI_CFG]= "NIC_MBOX_MSG_CPI_CFG",
+   [NIC_MBOX_MSG_RSS_SIZE]   = "NIC_MBOX_MSG_RSS_SIZE",
+   [NIC_MBOX_MSG_RSS_CFG]= "NIC_MBOX_MSG_RSS_CFG",
+   [NIC_MBOX_MSG_RSS_CFG_CONT]   = "NIC_MBOX_MSG_RSS_CFG_CONT",
+   [NIC_MBOX_MSG_RQ_BP_CFG]  = "NIC_MBOX_MSG_RQ_BP_CFG",
+   [NIC_MBOX_MSG_RQ_SW_SYNC] = "NIC_MBOX_MSG_RQ_SW_SYNC",
+   [NIC_MBOX_MSG_BGX_LINK_CHANGE]= "NIC_MBOX_MSG_BGX_LINK_CHANGE",
+   [NIC_MBOX_MSG_ALLOC_SQS]  = "NIC_MBOX_MSG_ALLOC_SQS",
+   [NIC_MBOX_MSG_LOOPBACK]   = "NIC_MBOX_MSG_LOOPBACK",
+   [NIC_MBOX_MSG_RESET_STAT_COUNTER] = "NIC_MBOX_MSG_RESET_STAT_COUNTER",
+   [NIC_MBOX_MSG_CFG_DONE]   = "NIC_MBOX_MSG_CFG_DONE",
+   [NIC_MBOX_MSG_SHUTDOWN]   = "NIC_MBOX_MSG_SHUTDOWN",
+};
+
+static inline const char *
+nicvf_mbox_msg_str(int msg)
+{
+   assert(msg >= 0 && msg < NIC_MBOX_MSG_MAX);
+   /* undefined messages */
+   if (mbox_message[msg] == NULL)
+   msg = 0;
+   return mbox_message[msg];
+}
+
+static inline void
+nicvf_mbox_send_msg_to_pf_raw(struct nicvf *nic, struct nic_mbx *mbx)
+{
+   uint64_t *mbx_data;
+   uint64_t mbx_addr;
+   int i;
+
+   mbx_addr = NIC_VF_PF_MAILBOX_0_1;
+   mbx_data = (uint64_t *)mbx;
+   for (i = 0; i < NIC_PF_VF_MAILBOX_SIZE; i++) {
+   nicvf_reg_write(nic, mbx_addr, *mbx_data);
+   mbx_data++;
+   mbx_addr += sizeof(uint64_t);
+   }
+   nicvf_mbox_log("msg sent %s (VF%d)",
+   

[dpdk-dev] [PATCH v5 05/25] net/thunderx/base: add hardware API for ThunderX nicvf inbuilt NIC

2016-06-15 Thread Jerin Jacob
add nicvf hardware specific APIs for initialization and configuration.

Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/base/nicvf_hw.c   | 731 +
 drivers/net/thunderx/base/nicvf_hw.h   | 176 
 drivers/net/thunderx/base/nicvf_plat.h |   1 +
 3 files changed, 908 insertions(+)
 create mode 100644 drivers/net/thunderx/base/nicvf_hw.c
 create mode 100644 drivers/net/thunderx/base/nicvf_hw.h

diff --git a/drivers/net/thunderx/base/nicvf_hw.c 
b/drivers/net/thunderx/base/nicvf_hw.c
new file mode 100644
index 000..ec24f9c
--- /dev/null
+++ b/drivers/net/thunderx/base/nicvf_hw.c
@@ -0,0 +1,731 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright (C) Cavium networks Ltd. 2016.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Cavium networks nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   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
+ *   OWNER 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "nicvf_plat.h"
+
+struct nicvf_reg_info {
+   uint32_t offset;
+   const char *name;
+};
+
+#define NICVF_REG_POLL_ITER_NR   (10)
+#define NICVF_REG_POLL_DELAY_US  (2000)
+#define NICVF_REG_INFO(reg) {reg, #reg}
+
+static const struct nicvf_reg_info nicvf_reg_tbl[] = {
+   NICVF_REG_INFO(NIC_VF_CFG),
+   NICVF_REG_INFO(NIC_VF_PF_MAILBOX_0_1),
+   NICVF_REG_INFO(NIC_VF_INT),
+   NICVF_REG_INFO(NIC_VF_INT_W1S),
+   NICVF_REG_INFO(NIC_VF_ENA_W1C),
+   NICVF_REG_INFO(NIC_VF_ENA_W1S),
+   NICVF_REG_INFO(NIC_VNIC_RSS_CFG),
+   NICVF_REG_INFO(NIC_VNIC_RQ_GEN_CFG),
+};
+
+static const struct nicvf_reg_info nicvf_multi_reg_tbl[] = {
+   {NIC_VNIC_RSS_KEY_0_4 + 0,  "NIC_VNIC_RSS_KEY_0"},
+   {NIC_VNIC_RSS_KEY_0_4 + 8,  "NIC_VNIC_RSS_KEY_1"},
+   {NIC_VNIC_RSS_KEY_0_4 + 16, "NIC_VNIC_RSS_KEY_2"},
+   {NIC_VNIC_RSS_KEY_0_4 + 24, "NIC_VNIC_RSS_KEY_3"},
+   {NIC_VNIC_RSS_KEY_0_4 + 32, "NIC_VNIC_RSS_KEY_4"},
+   {NIC_VNIC_TX_STAT_0_4 + 0,  "NIC_VNIC_STAT_TX_OCTS"},
+   {NIC_VNIC_TX_STAT_0_4 + 8,  "NIC_VNIC_STAT_TX_UCAST"},
+   {NIC_VNIC_TX_STAT_0_4 + 16,  "NIC_VNIC_STAT_TX_BCAST"},
+   {NIC_VNIC_TX_STAT_0_4 + 24,  "NIC_VNIC_STAT_TX_MCAST"},
+   {NIC_VNIC_TX_STAT_0_4 + 32,  "NIC_VNIC_STAT_TX_DROP"},
+   {NIC_VNIC_RX_STAT_0_13 + 0,  "NIC_VNIC_STAT_RX_OCTS"},
+   {NIC_VNIC_RX_STAT_0_13 + 8,  "NIC_VNIC_STAT_RX_UCAST"},
+   {NIC_VNIC_RX_STAT_0_13 + 16, "NIC_VNIC_STAT_RX_BCAST"},
+   {NIC_VNIC_RX_STAT_0_13 + 24, "NIC_VNIC_STAT_RX_MCAST"},
+   {NIC_VNIC_RX_STAT_0_13 + 32, "NIC_VNIC_STAT_RX_RED"},
+   {NIC_VNIC_RX_STAT_0_13 + 40, "NIC_VNIC_STAT_RX_RED_OCTS"},
+   {NIC_VNIC_RX_STAT_0_13 + 48, "NIC_VNIC_STAT_RX_ORUN"},
+   {NIC_VNIC_RX_STAT_0_13 + 56, "NIC_VNIC_STAT_RX_ORUN_OCTS"},
+   {NIC_VNIC_RX_STAT_0_13 + 64, "NIC_VNIC_STAT_RX_FCS"},
+   {NIC_VNIC_RX_STAT_0_13 + 72, "NIC_VNIC_STAT_RX_L2ERR"},
+   {NIC_VNIC_RX_STAT_0_13 + 80, "NIC_VNIC_STAT_RX_DRP_BCAST"},
+   {NIC_VNIC_RX_STAT_0_13 + 88, "NIC_VNIC_STAT_RX_DRP_MCAST"},
+   {NIC_VNIC_RX_STAT_0_13 + 96, "NIC_VNIC_STAT_RX_DRP_L3BCAST"},
+   {NIC_VNIC_RX_STAT_0_13 + 104, "NIC_VNIC_STAT_RX_DRP_L3MCAST"},
+};
+
+static const struct nicvf_reg_info nicvf_qset_cq_reg_tbl[] = {
+   NICVF_REG_INFO(NIC_QSET_CQ_0_7_CFG),
+   NICVF_REG_INFO(NIC_QSET_CQ_0_7_CFG2),
+   NICVF_REG_INFO(NIC_QSET_CQ_0_7_THRESH),

[dpdk-dev] [PATCH v5 06/25] net/thunderx/base: add RSS and reta configuration HW APIs

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/base/nicvf_hw.c | 129 +++
 drivers/net/thunderx/base/nicvf_hw.h |  20 ++
 2 files changed, 149 insertions(+)

diff --git a/drivers/net/thunderx/base/nicvf_hw.c 
b/drivers/net/thunderx/base/nicvf_hw.c
index ec24f9c..3366aa5 100644
--- a/drivers/net/thunderx/base/nicvf_hw.c
+++ b/drivers/net/thunderx/base/nicvf_hw.c
@@ -721,6 +721,135 @@ nicvf_vlan_hw_strip(struct nicvf *nic, bool enable)
nicvf_reg_write(nic, NIC_VNIC_RQ_GEN_CFG, val);
 }

+void
+nicvf_rss_set_key(struct nicvf *nic, uint8_t *key)
+{
+   int idx;
+   uint64_t addr, val;
+   uint64_t *keyptr = (uint64_t *)key;
+
+   addr = NIC_VNIC_RSS_KEY_0_4;
+   for (idx = 0; idx < RSS_HASH_KEY_SIZE; idx++) {
+   val = nicvf_cpu_to_be_64(*keyptr);
+   nicvf_reg_write(nic, addr, val);
+   addr += sizeof(uint64_t);
+   keyptr++;
+   }
+}
+
+void
+nicvf_rss_get_key(struct nicvf *nic, uint8_t *key)
+{
+   int idx;
+   uint64_t addr, val;
+   uint64_t *keyptr = (uint64_t *)key;
+
+   addr = NIC_VNIC_RSS_KEY_0_4;
+   for (idx = 0; idx < RSS_HASH_KEY_SIZE; idx++) {
+   val = nicvf_reg_read(nic, addr);
+   *keyptr = nicvf_be_to_cpu_64(val);
+   addr += sizeof(uint64_t);
+   keyptr++;
+   }
+}
+
+void
+nicvf_rss_set_cfg(struct nicvf *nic, uint64_t val)
+{
+   nicvf_reg_write(nic, NIC_VNIC_RSS_CFG, val);
+}
+
+uint64_t
+nicvf_rss_get_cfg(struct nicvf *nic)
+{
+   return nicvf_reg_read(nic, NIC_VNIC_RSS_CFG);
+}
+
+int
+nicvf_rss_reta_update(struct nicvf *nic, uint8_t *tbl, uint32_t max_count)
+{
+   uint32_t idx;
+   struct nicvf_rss_reta_info *rss = >rss_info;
+
+   /* result will be stored in nic->rss_info.rss_size */
+   if (nicvf_mbox_get_rss_size(nic))
+   return NICVF_ERR_RSS_GET_SZ;
+
+   assert(rss->rss_size > 0);
+   rss->hash_bits = (uint8_t)log2(rss->rss_size);
+   for (idx = 0; idx < rss->rss_size && idx < max_count; idx++)
+   rss->ind_tbl[idx] = tbl[idx];
+
+   if (nicvf_mbox_config_rss(nic))
+   return NICVF_ERR_RSS_TBL_UPDATE;
+
+   return NICVF_OK;
+}
+
+int
+nicvf_rss_reta_query(struct nicvf *nic, uint8_t *tbl, uint32_t max_count)
+{
+   uint32_t idx;
+   struct nicvf_rss_reta_info *rss = >rss_info;
+
+   /* result will be stored in nic->rss_info.rss_size */
+   if (nicvf_mbox_get_rss_size(nic))
+   return NICVF_ERR_RSS_GET_SZ;
+
+   assert(rss->rss_size > 0);
+   rss->hash_bits = (uint8_t)log2(rss->rss_size);
+   for (idx = 0; idx < rss->rss_size && idx < max_count; idx++)
+   tbl[idx] = rss->ind_tbl[idx];
+
+   return NICVF_OK;
+}
+
+int
+nicvf_rss_config(struct nicvf *nic, uint32_t  qcnt, uint64_t cfg)
+{
+   uint32_t idx;
+   uint8_t default_reta[NIC_MAX_RSS_IDR_TBL_SIZE];
+   uint8_t default_key[RSS_HASH_KEY_BYTE_SIZE] = {
+   0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD,
+   0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD,
+   0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD,
+   0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD,
+   0xFE, 0xED, 0x0B, 0xAD, 0xFE, 0xED, 0x0B, 0xAD
+   };
+
+   if (nic->cpi_alg != CPI_ALG_NONE)
+   return -EINVAL;
+
+   if (cfg == 0)
+   return -EINVAL;
+
+   /* Update default RSS key and cfg */
+   nicvf_rss_set_key(nic, default_key);
+   nicvf_rss_set_cfg(nic, cfg);
+
+   /* Update default RSS RETA */
+   for (idx = 0; idx < NIC_MAX_RSS_IDR_TBL_SIZE; idx++)
+   default_reta[idx] = idx % qcnt;
+
+   return nicvf_rss_reta_update(nic, default_reta,
+   NIC_MAX_RSS_IDR_TBL_SIZE);
+}
+
+int
+nicvf_rss_term(struct nicvf *nic)
+{
+   uint32_t idx;
+   uint8_t disable_rss[NIC_MAX_RSS_IDR_TBL_SIZE];
+
+   nicvf_rss_set_cfg(nic, 0);
+   /* Redirect the output to 0th queue  */
+   for (idx = 0; idx < NIC_MAX_RSS_IDR_TBL_SIZE; idx++)
+   disable_rss[idx] = 0;
+
+   return nicvf_rss_reta_update(nic, disable_rss,
+   NIC_MAX_RSS_IDR_TBL_SIZE);
+}
+
 int
 nicvf_loopback_config(struct nicvf *nic, bool enable)
 {
diff --git a/drivers/net/thunderx/base/nicvf_hw.h 
b/drivers/net/thunderx/base/nicvf_hw.h
index dc9f4f1..a7ae531 100644
--- a/drivers/net/thunderx/base/nicvf_hw.h
+++ b/drivers/net/thunderx/base/nicvf_hw.h
@@ -76,10 +76,18 @@ enum nicvf_err_e {
NICVF_ERR_SQ_PF_CFG, /* -8175 */
NICVF_ERR_LOOPBACK_CFG,  /* -8174 */
NICVF_ERR_BASE_INIT, /* -8173 */
+   NICVF_ERR_RSS_TBL_UPDATE,/* -8172 */
+   NICVF_ERR_RSS_GET_SZ,/* -8171 */
 };

 typedef 

[dpdk-dev] [PATCH v5 07/25] net/thunderx/base: add statistics get HW APIs

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/base/nicvf_hw.c | 45 
 drivers/net/thunderx/base/nicvf_hw.h | 44 +++
 2 files changed, 89 insertions(+)

diff --git a/drivers/net/thunderx/base/nicvf_hw.c 
b/drivers/net/thunderx/base/nicvf_hw.c
index 3366aa5..001b0ed 100644
--- a/drivers/net/thunderx/base/nicvf_hw.c
+++ b/drivers/net/thunderx/base/nicvf_hw.c
@@ -858,3 +858,48 @@ nicvf_loopback_config(struct nicvf *nic, bool enable)

return nicvf_mbox_loopback_config(nic, enable);
 }
+
+void
+nicvf_hw_get_stats(struct nicvf *nic, struct nicvf_hw_stats *stats)
+{
+   stats->rx_bytes = NICVF_GET_RX_STATS(RX_OCTS);
+   stats->rx_ucast_frames = NICVF_GET_RX_STATS(RX_UCAST);
+   stats->rx_bcast_frames = NICVF_GET_RX_STATS(RX_BCAST);
+   stats->rx_mcast_frames = NICVF_GET_RX_STATS(RX_MCAST);
+   stats->rx_fcs_errors = NICVF_GET_RX_STATS(RX_FCS);
+   stats->rx_l2_errors = NICVF_GET_RX_STATS(RX_L2ERR);
+   stats->rx_drop_red = NICVF_GET_RX_STATS(RX_RED);
+   stats->rx_drop_red_bytes = NICVF_GET_RX_STATS(RX_RED_OCTS);
+   stats->rx_drop_overrun = NICVF_GET_RX_STATS(RX_ORUN);
+   stats->rx_drop_overrun_bytes = NICVF_GET_RX_STATS(RX_ORUN_OCTS);
+   stats->rx_drop_bcast = NICVF_GET_RX_STATS(RX_DRP_BCAST);
+   stats->rx_drop_mcast = NICVF_GET_RX_STATS(RX_DRP_MCAST);
+   stats->rx_drop_l3_bcast = NICVF_GET_RX_STATS(RX_DRP_L3BCAST);
+   stats->rx_drop_l3_mcast = NICVF_GET_RX_STATS(RX_DRP_L3MCAST);
+
+   stats->tx_bytes_ok = NICVF_GET_TX_STATS(TX_OCTS);
+   stats->tx_ucast_frames_ok = NICVF_GET_TX_STATS(TX_UCAST);
+   stats->tx_bcast_frames_ok = NICVF_GET_TX_STATS(TX_BCAST);
+   stats->tx_mcast_frames_ok = NICVF_GET_TX_STATS(TX_MCAST);
+   stats->tx_drops = NICVF_GET_TX_STATS(TX_DROP);
+}
+
+void
+nicvf_hw_get_rx_qstats(struct nicvf *nic, struct nicvf_hw_rx_qstats *qstats,
+  uint16_t qidx)
+{
+   qstats->q_rx_bytes =
+   nicvf_queue_reg_read(nic, NIC_QSET_RQ_0_7_STATUS0, qidx);
+   qstats->q_rx_packets =
+   nicvf_queue_reg_read(nic, NIC_QSET_RQ_0_7_STATUS1, qidx);
+}
+
+void
+nicvf_hw_get_tx_qstats(struct nicvf *nic, struct nicvf_hw_tx_qstats *qstats,
+  uint16_t qidx)
+{
+   qstats->q_tx_bytes =
+   nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STATUS0, qidx);
+   qstats->q_tx_packets =
+   nicvf_queue_reg_read(nic, NIC_QSET_SQ_0_7_STATUS1, qidx);
+}
diff --git a/drivers/net/thunderx/base/nicvf_hw.h 
b/drivers/net/thunderx/base/nicvf_hw.h
index a7ae531..9db1d30 100644
--- a/drivers/net/thunderx/base/nicvf_hw.h
+++ b/drivers/net/thunderx/base/nicvf_hw.h
@@ -45,6 +45,11 @@

 #define NICVF_ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

+#define NICVF_GET_RX_STATS(reg) \
+   nicvf_reg_read(nic, NIC_VNIC_RX_STAT_0_13 | (reg << 3))
+#define NICVF_GET_TX_STATS(reg) \
+   nicvf_reg_read(nic, NIC_VNIC_TX_STAT_0_4 | (reg << 3))
+
 #define NICVF_PASS1(PCI_SUB_DEVICE_ID_THUNDERX_PASS1_NICVF)
 #define NICVF_PASS2(PCI_SUB_DEVICE_ID_THUNDERX_PASS2_NICVF)

@@ -82,6 +87,39 @@ enum nicvf_err_e {

 typedef nicvf_phys_addr_t (*rbdr_pool_get_handler)(void *opaque);

+struct nicvf_hw_rx_qstats {
+   uint64_t q_rx_bytes;
+   uint64_t q_rx_packets;
+};
+
+struct nicvf_hw_tx_qstats {
+   uint64_t q_tx_bytes;
+   uint64_t q_tx_packets;
+};
+
+struct nicvf_hw_stats {
+   uint64_t rx_bytes;
+   uint64_t rx_ucast_frames;
+   uint64_t rx_bcast_frames;
+   uint64_t rx_mcast_frames;
+   uint64_t rx_fcs_errors;
+   uint64_t rx_l2_errors;
+   uint64_t rx_drop_red;
+   uint64_t rx_drop_red_bytes;
+   uint64_t rx_drop_overrun;
+   uint64_t rx_drop_overrun_bytes;
+   uint64_t rx_drop_bcast;
+   uint64_t rx_drop_mcast;
+   uint64_t rx_drop_l3_bcast;
+   uint64_t rx_drop_l3_mcast;
+
+   uint64_t tx_bytes_ok;
+   uint64_t tx_ucast_frames_ok;
+   uint64_t tx_bcast_frames_ok;
+   uint64_t tx_mcast_frames_ok;
+   uint64_t tx_drops;
+};
+
 struct nicvf_rss_reta_info {
uint8_t hash_bits;
uint16_t rss_size;
@@ -193,4 +231,10 @@ uint64_t nicvf_rss_get_cfg(struct nicvf *nic);

 int nicvf_loopback_config(struct nicvf *nic, bool enable);

+void nicvf_hw_get_stats(struct nicvf *nic, struct nicvf_hw_stats *stats);
+void nicvf_hw_get_rx_qstats(struct nicvf *nic,
+   struct nicvf_hw_rx_qstats *qstats, uint16_t qidx);
+void nicvf_hw_get_tx_qstats(struct nicvf *nic,
+   struct nicvf_hw_tx_qstats *qstats, uint16_t qidx);
+
 #endif /* _THUNDERX_NICVF_HW_H */
-- 
2.5.5



[dpdk-dev] [PATCH v5 08/25] net/thunderx: add pmd skeleton

2016-06-15 Thread Jerin Jacob
Introduce driver initialization and enable build infrastructure for
nicvf pmd driver.

By default, It is enabled only for defconfig_arm64-thunderx-*
config as it is an inbuilt NIC device.

Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 config/common_base |  10 +
 config/defconfig_arm64-thunderx-linuxapp-gcc   |  10 +
 drivers/net/Makefile   |   1 +
 drivers/net/thunderx/Makefile  |  63 ++
 drivers/net/thunderx/nicvf_ethdev.c| 251 +
 drivers/net/thunderx/nicvf_ethdev.h|  48 
 drivers/net/thunderx/nicvf_logs.h  |  83 +++
 drivers/net/thunderx/nicvf_struct.h| 124 ++
 .../thunderx/rte_pmd_thunderx_nicvf_version.map|   4 +
 mk/rte.app.mk  |   2 +
 10 files changed, 596 insertions(+)
 create mode 100644 drivers/net/thunderx/Makefile
 create mode 100644 drivers/net/thunderx/nicvf_ethdev.c
 create mode 100644 drivers/net/thunderx/nicvf_ethdev.h
 create mode 100644 drivers/net/thunderx/nicvf_logs.h
 create mode 100644 drivers/net/thunderx/nicvf_struct.h
 create mode 100644 drivers/net/thunderx/rte_pmd_thunderx_nicvf_version.map

diff --git a/config/common_base b/config/common_base
index 47c26f6..ad5686b 100644
--- a/config/common_base
+++ b/config/common_base
@@ -259,6 +259,16 @@ CONFIG_RTE_LIBRTE_PMD_SZEDATA2=n
 CONFIG_RTE_LIBRTE_PMD_SZEDATA2_AS=0

 #
+# Compile burst-oriented Cavium Thunderx NICVF PMD driver
+#
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_INIT=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_RX=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_DRIVER=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_MBOX=n
+
+#
 # Compile burst-oriented VIRTIO PMD driver
 #
 CONFIG_RTE_LIBRTE_VIRTIO_PMD=y
diff --git a/config/defconfig_arm64-thunderx-linuxapp-gcc 
b/config/defconfig_arm64-thunderx-linuxapp-gcc
index fe5e987..7940bbd 100644
--- a/config/defconfig_arm64-thunderx-linuxapp-gcc
+++ b/config/defconfig_arm64-thunderx-linuxapp-gcc
@@ -34,3 +34,13 @@
 CONFIG_RTE_MACHINE="thunderx"

 CONFIG_RTE_CACHE_LINE_SIZE=128
+
+#
+# Compile Cavium Thunderx NICVF PMD driver
+#
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD=y
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_INIT=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_RX=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_TX=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_DRIVER=n
+CONFIG_RTE_LIBRTE_THUNDERX_NICVF_DEBUG_MBOX=n
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 6ba7658..0e29a33 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -50,6 +50,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_PMD_PCAP) += pcap
 DIRS-$(CONFIG_RTE_LIBRTE_QEDE_PMD) += qede
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_RING) += ring
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_SZEDATA2) += szedata2
+DIRS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += thunderx
 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
diff --git a/drivers/net/thunderx/Makefile b/drivers/net/thunderx/Makefile
new file mode 100644
index 000..eb9f100
--- /dev/null
+++ b/drivers/net/thunderx/Makefile
@@ -0,0 +1,63 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Cavium Networks. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * 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.
+# * Neither the name of Cavium Networks nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   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
+#   OWNER 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 

[dpdk-dev] [PATCH v5 09/25] net/thunderx: add link status and link update support

2016-06-15 Thread Jerin Jacob
Extended the nicvf_interrupt function to respond
NIC_MBOX_MSG_BGX_LINK_CHANGE mbox message from PF and update
struct rte_eth_link accordingly.

Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 53 -
 drivers/net/thunderx/nicvf_ethdev.h |  4 +++
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 3ca5a2b..6fa486a 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -69,12 +69,45 @@

 #include "nicvf_logs.h"

+static inline int
+nicvf_atomic_write_link_status(struct rte_eth_dev *dev,
+  struct rte_eth_link *link)
+{
+   struct rte_eth_link *dst = >data->dev_link;
+   struct rte_eth_link *src = link;
+
+   if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
+   *(uint64_t *)src) == 0)
+   return -1;
+
+   return 0;
+}
+
+static inline void
+nicvf_set_eth_link_status(struct nicvf *nic, struct rte_eth_link *link)
+{
+   link->link_status = nic->link_up;
+   link->link_duplex = ETH_LINK_AUTONEG;
+   if (nic->duplex == NICVF_HALF_DUPLEX)
+   link->link_duplex = ETH_LINK_HALF_DUPLEX;
+   else if (nic->duplex == NICVF_FULL_DUPLEX)
+   link->link_duplex = ETH_LINK_FULL_DUPLEX;
+   link->link_speed = nic->speed;
+   link->link_autoneg = ETH_LINK_SPEED_AUTONEG;
+}
+
 static void
 nicvf_interrupt(void *arg)
 {
struct nicvf *nic = arg;

-   nicvf_reg_poll_interrupts(nic);
+   if (nicvf_reg_poll_interrupts(nic) == NIC_MBOX_MSG_BGX_LINK_CHANGE) {
+   if (nic->eth_dev->data->dev_conf.intr_conf.lsc)
+   nicvf_set_eth_link_status(nic,
+   >eth_dev->data->dev_link);
+   _rte_eth_dev_callback_process(nic->eth_dev,
+   RTE_ETH_EVENT_INTR_LSC);
+   }

rte_eal_alarm_set(NICVF_INTR_POLL_INTERVAL_MS * 1000,
nicvf_interrupt, nic);
@@ -93,8 +126,26 @@ nicvf_periodic_alarm_stop(struct nicvf *nic)
return rte_eal_alarm_cancel(nicvf_interrupt, nic);
 }

+/*
+ * Return 0 means link status changed, -1 means not changed
+ */
+static int
+nicvf_dev_link_update(struct rte_eth_dev *dev,
+ int wait_to_complete __rte_unused)
+{
+   struct rte_eth_link link;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   PMD_INIT_FUNC_TRACE();
+
+   memset(, 0, sizeof(link));
+   nicvf_set_eth_link_status(nic, );
+   return nicvf_atomic_write_link_status(dev, );
+}
+
 /* Initialize and register driver with DPDK Application */
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
+   .link_update  = nicvf_dev_link_update,
 };

 static int
diff --git a/drivers/net/thunderx/nicvf_ethdev.h 
b/drivers/net/thunderx/nicvf_ethdev.h
index d4d2071..8189856 100644
--- a/drivers/net/thunderx/nicvf_ethdev.h
+++ b/drivers/net/thunderx/nicvf_ethdev.h
@@ -38,6 +38,10 @@
 #define THUNDERX_NICVF_PMD_VERSION  "1.0"

 #define NICVF_INTR_POLL_INTERVAL_MS50
+#define NICVF_HALF_DUPLEX  0x00
+#define NICVF_FULL_DUPLEX  0x01
+#define NICVF_UNKNOWN_DUPLEX   0xff
+

 static inline struct nicvf *
 nicvf_pmd_priv(struct rte_eth_dev *eth_dev)
-- 
2.5.5



[dpdk-dev] [PATCH v5 10/25] net/thunderx: add registers dump support

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/nicvf_ethdev.c | 27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 6fa486a..5c066e2 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -143,9 +143,36 @@ nicvf_dev_link_update(struct rte_eth_dev *dev,
return nicvf_atomic_write_link_status(dev, );
 }

+static int
+nicvf_dev_get_reg_length(struct rte_eth_dev *dev  __rte_unused)
+{
+   return nicvf_reg_get_count();
+}
+
+static int
+nicvf_dev_get_regs(struct rte_eth_dev *dev, struct rte_dev_reg_info *regs)
+{
+   uint64_t *data = regs->data;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   if (data == NULL)
+   return -EINVAL;
+
+   /* Support only full register dump */
+   if ((regs->length == 0) ||
+   (regs->length == (uint32_t)nicvf_reg_get_count())) {
+   regs->version = nic->vendor_id << 16 | nic->device_id;
+   nicvf_reg_dump(nic, data);
+   return 0;
+   }
+   return -ENOTSUP;
+}
+
 /* Initialize and register driver with DPDK Application */
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
.link_update  = nicvf_dev_link_update,
+   .get_reg_length   = nicvf_dev_get_reg_length,
+   .get_reg  = nicvf_dev_get_regs,
 };

 static int
-- 
2.5.5



[dpdk-dev] [PATCH v5 11/25] net/thunderx: add ethdev configure support

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 78 +
 1 file changed, 78 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 5c066e2..1814341 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -168,8 +168,86 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct 
rte_dev_reg_info *regs)
return -ENOTSUP;
 }

+static int
+nicvf_dev_configure(struct rte_eth_dev *dev)
+{
+   struct rte_eth_conf *conf = >data->dev_conf;
+   struct rte_eth_rxmode *rxmode = >rxmode;
+   struct rte_eth_txmode *txmode = >txmode;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (!rte_eal_has_hugepages()) {
+   PMD_INIT_LOG(INFO, "Huge page is not configured");
+   return -EINVAL;
+   }
+
+   if (txmode->mq_mode) {
+   PMD_INIT_LOG(INFO, "Tx mq_mode DCB or VMDq not supported");
+   return -EINVAL;
+   }
+
+   if (rxmode->mq_mode != ETH_MQ_RX_NONE &&
+   rxmode->mq_mode != ETH_MQ_RX_RSS) {
+   PMD_INIT_LOG(INFO, "Unsupported rx qmode %d", rxmode->mq_mode);
+   return -EINVAL;
+   }
+
+   if (!rxmode->hw_strip_crc) {
+   PMD_INIT_LOG(NOTICE, "Can't disable hw crc strip");
+   rxmode->hw_strip_crc = 1;
+   }
+
+   if (rxmode->hw_ip_checksum) {
+   PMD_INIT_LOG(NOTICE, "Rxcksum not supported");
+   rxmode->hw_ip_checksum = 0;
+   }
+
+   if (rxmode->split_hdr_size) {
+   PMD_INIT_LOG(INFO, "Rxmode does not support split header");
+   return -EINVAL;
+   }
+
+   if (rxmode->hw_vlan_filter) {
+   PMD_INIT_LOG(INFO, "VLAN filter not supported");
+   return -EINVAL;
+   }
+
+   if (rxmode->hw_vlan_extend) {
+   PMD_INIT_LOG(INFO, "VLAN extended not supported");
+   return -EINVAL;
+   }
+
+   if (rxmode->enable_lro) {
+   PMD_INIT_LOG(INFO, "LRO not supported");
+   return -EINVAL;
+   }
+
+   if (conf->link_speeds & ETH_LINK_SPEED_FIXED) {
+   PMD_INIT_LOG(INFO, "Setting link speed/duplex not supported");
+   return -EINVAL;
+   }
+
+   if (conf->dcb_capability_en) {
+   PMD_INIT_LOG(INFO, "DCB enable not supported");
+   return -EINVAL;
+   }
+
+   if (conf->fdir_conf.mode != RTE_FDIR_MODE_NONE) {
+   PMD_INIT_LOG(INFO, "Flow director not supported");
+   return -EINVAL;
+   }
+
+   PMD_INIT_LOG(DEBUG, "Configured ethdev port%d hwcap=0x%" PRIx64,
+   dev->data->port_id, nicvf_hw_cap(nic));
+
+   return 0;
+}
+
 /* Initialize and register driver with DPDK Application */
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
+   .dev_configure= nicvf_dev_configure,
.link_update  = nicvf_dev_link_update,
.get_reg_length   = nicvf_dev_get_reg_length,
.get_reg  = nicvf_dev_get_regs,
-- 
2.5.5



[dpdk-dev] [PATCH v5 12/25] net/thunderx: add get device info support

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 45 +
 drivers/net/thunderx/nicvf_ethdev.h | 17 ++
 2 files changed, 62 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 1814341..109c6cb 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -168,6 +168,50 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct 
rte_dev_reg_info *regs)
return -ENOTSUP;
 }

+static void
+nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   PMD_INIT_FUNC_TRACE();
+
+   dev_info->min_rx_bufsize = ETHER_MIN_MTU;
+   dev_info->max_rx_pktlen = NIC_HW_MAX_FRS;
+   dev_info->max_rx_queues = (uint16_t)MAX_RCV_QUEUES_PER_QS;
+   dev_info->max_tx_queues = (uint16_t)MAX_SND_QUEUES_PER_QS;
+   dev_info->max_mac_addrs = 1;
+   dev_info->max_vfs = dev->pci_dev->max_vfs;
+
+   dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP;
+   dev_info->tx_offload_capa =
+   DEV_TX_OFFLOAD_IPV4_CKSUM  |
+   DEV_TX_OFFLOAD_UDP_CKSUM   |
+   DEV_TX_OFFLOAD_TCP_CKSUM   |
+   DEV_TX_OFFLOAD_TCP_TSO |
+   DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+
+   dev_info->reta_size = nic->rss_info.rss_size;
+   dev_info->hash_key_size = RSS_HASH_KEY_BYTE_SIZE;
+   dev_info->flow_type_rss_offloads = NICVF_RSS_OFFLOAD_PASS1;
+   if (nicvf_hw_cap(nic) & NICVF_CAP_TUNNEL_PARSING)
+   dev_info->flow_type_rss_offloads |= NICVF_RSS_OFFLOAD_TUNNEL;
+
+   dev_info->default_rxconf = (struct rte_eth_rxconf) {
+   .rx_free_thresh = NICVF_DEFAULT_RX_FREE_THRESH,
+   .rx_drop_en = 0,
+   };
+
+   dev_info->default_txconf = (struct rte_eth_txconf) {
+   .tx_free_thresh = NICVF_DEFAULT_TX_FREE_THRESH,
+   .txq_flags =
+   ETH_TXQ_FLAGS_NOMULTSEGS  |
+   ETH_TXQ_FLAGS_NOREFCOUNT  |
+   ETH_TXQ_FLAGS_NOMULTMEMP  |
+   ETH_TXQ_FLAGS_NOVLANOFFL  |
+   ETH_TXQ_FLAGS_NOXSUMSCTP,
+   };
+}
+
 static int
 nicvf_dev_configure(struct rte_eth_dev *dev)
 {
@@ -249,6 +293,7 @@ nicvf_dev_configure(struct rte_eth_dev *dev)
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
.dev_configure= nicvf_dev_configure,
.link_update  = nicvf_dev_link_update,
+   .dev_infos_get= nicvf_dev_info_get,
.get_reg_length   = nicvf_dev_get_reg_length,
.get_reg  = nicvf_dev_get_regs,
 };
diff --git a/drivers/net/thunderx/nicvf_ethdev.h 
b/drivers/net/thunderx/nicvf_ethdev.h
index 8189856..e31657d 100644
--- a/drivers/net/thunderx/nicvf_ethdev.h
+++ b/drivers/net/thunderx/nicvf_ethdev.h
@@ -42,6 +42,23 @@
 #define NICVF_FULL_DUPLEX  0x01
 #define NICVF_UNKNOWN_DUPLEX   0xff

+#define NICVF_RSS_OFFLOAD_PASS1 ( \
+   ETH_RSS_PORT | \
+   ETH_RSS_IPV4 | \
+   ETH_RSS_NONFRAG_IPV4_TCP | \
+   ETH_RSS_NONFRAG_IPV4_UDP | \
+   ETH_RSS_IPV6 | \
+   ETH_RSS_NONFRAG_IPV6_TCP | \
+   ETH_RSS_NONFRAG_IPV6_UDP)
+
+#define NICVF_RSS_OFFLOAD_TUNNEL ( \
+   ETH_RSS_VXLAN | \
+   ETH_RSS_GENEVE | \
+   ETH_RSS_NVGRE)
+
+#define NICVF_DEFAULT_RX_FREE_THRESH224
+#define NICVF_DEFAULT_TX_FREE_THRESH224
+#define NICVF_TX_FREE_MPOOL_THRESH  16

 static inline struct nicvf *
 nicvf_pmd_priv(struct rte_eth_dev *eth_dev)
-- 
2.5.5



[dpdk-dev] [PATCH v5 13/25] net/thunderx: add Rx queue setup and release support

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 136 
 drivers/net/thunderx/nicvf_ethdev.h |   2 +
 2 files changed, 138 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 109c6cb..4652438 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -168,6 +168,140 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct 
rte_dev_reg_info *regs)
return -ENOTSUP;
 }

+static int
+nicvf_qset_cq_alloc(struct nicvf *nic, struct nicvf_rxq *rxq, uint16_t qidx,
+   uint32_t desc_cnt)
+{
+   const struct rte_memzone *rz;
+   uint32_t ring_size = desc_cnt * sizeof(union cq_entry_t);
+
+   rz = rte_eth_dma_zone_reserve(nic->eth_dev, "cq_ring", qidx, ring_size,
+   NICVF_CQ_BASE_ALIGN_BYTES, nic->node);
+   if (rz == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate mem for cq hw ring");
+   return -ENOMEM;
+   }
+
+   memset(rz->addr, 0, ring_size);
+
+   rxq->phys = rz->phys_addr;
+   rxq->desc = rz->addr;
+   rxq->qlen_mask = desc_cnt - 1;
+
+   return 0;
+}
+
+static void
+nicvf_rx_queue_reset(struct nicvf_rxq *rxq)
+{
+   rxq->head = 0;
+   rxq->available_space = 0;
+   rxq->recv_buffers = 0;
+}
+
+static void
+nicvf_dev_rx_queue_release(void *rx_queue)
+{
+   struct nicvf_rxq *rxq = rx_queue;
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (rxq)
+   rte_free(rxq);
+}
+
+static int
+nicvf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
+uint16_t nb_desc, unsigned int socket_id,
+const struct rte_eth_rxconf *rx_conf,
+struct rte_mempool *mp)
+{
+   uint16_t rx_free_thresh;
+   struct nicvf_rxq *rxq;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   PMD_INIT_FUNC_TRACE();
+
+   /* Socket id check */
+   if (socket_id != (unsigned int)SOCKET_ID_ANY && socket_id != nic->node)
+   PMD_DRV_LOG(WARNING, "socket_id expected %d, configured %d",
+   socket_id, nic->node);
+
+   /* Mempool memory should be contiguous */
+   if (mp->nb_mem_chunks != 1) {
+   PMD_INIT_LOG(ERR, "Non contiguous mempool, check huge page sz");
+   return -EINVAL;
+   }
+
+   /* Rx deferred start is not supported */
+   if (rx_conf->rx_deferred_start) {
+   PMD_INIT_LOG(ERR, "Rx deferred start not supported");
+   return -EINVAL;
+   }
+
+   /* Roundup nb_desc to available qsize and validate max number of desc */
+   nb_desc = nicvf_qsize_cq_roundup(nb_desc);
+   if (nb_desc == 0) {
+   PMD_INIT_LOG(ERR, "Value nb_desc beyond available hw cq qsize");
+   return -EINVAL;
+   }
+
+   /* Check rx_free_thresh upper bound */
+   rx_free_thresh = (uint16_t)((rx_conf->rx_free_thresh) ?
+   rx_conf->rx_free_thresh :
+   NICVF_DEFAULT_RX_FREE_THRESH);
+   if (rx_free_thresh > NICVF_MAX_RX_FREE_THRESH ||
+   rx_free_thresh >= nb_desc * .75) {
+   PMD_INIT_LOG(ERR, "rx_free_thresh greater than expected %d",
+   rx_free_thresh);
+   return -EINVAL;
+   }
+
+   /* Free memory prior to re-allocation if needed */
+   if (dev->data->rx_queues[qidx] != NULL) {
+   PMD_RX_LOG(DEBUG, "Freeing memory prior to re-allocation %d",
+   qidx);
+   nicvf_dev_rx_queue_release(dev->data->rx_queues[qidx]);
+   dev->data->rx_queues[qidx] = NULL;
+   }
+
+   /* Allocate rxq memory */
+   rxq = rte_zmalloc_socket("ethdev rx queue", sizeof(struct nicvf_rxq),
+   RTE_CACHE_LINE_SIZE, nic->node);
+   if (rxq == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate rxq=%d", qidx);
+   return -ENOMEM;
+   }
+
+   rxq->nic = nic;
+   rxq->pool = mp;
+   rxq->queue_id = qidx;
+   rxq->port_id = dev->data->port_id;
+   rxq->rx_free_thresh = rx_free_thresh;
+   rxq->rx_drop_en = rx_conf->rx_drop_en;
+   rxq->cq_status = nicvf_qset_base(nic, qidx) + NIC_QSET_CQ_0_7_STATUS;
+   rxq->cq_door = nicvf_qset_base(nic, qidx) + NIC_QSET_CQ_0_7_DOOR;
+   rxq->precharge_cnt = 0;
+   rxq->rbptr_offset = NICVF_CQE_RBPTR_WORD;
+
+   /* Alloc completion queue */
+   if (nicvf_qset_cq_alloc(nic, rxq, rxq->queue_id, nb_desc)) {
+   PMD_INIT_LOG(ERR, "failed to allocate cq %u", rxq->queue_id);
+   nicvf_dev_rx_queue_release(rxq);
+   

[dpdk-dev] [PATCH v5 14/25] net/thunderx: add Tx queue setup and release support

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/nicvf_ethdev.c | 175 
 1 file changed, 175 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 4652438..167149e 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -191,6 +191,179 @@ nicvf_qset_cq_alloc(struct nicvf *nic, struct nicvf_rxq 
*rxq, uint16_t qidx,
return 0;
 }

+static int
+nicvf_qset_sq_alloc(struct nicvf *nic,  struct nicvf_txq *sq, uint16_t qidx,
+   uint32_t desc_cnt)
+{
+   const struct rte_memzone *rz;
+   uint32_t ring_size = desc_cnt * sizeof(union sq_entry_t);
+
+   rz = rte_eth_dma_zone_reserve(nic->eth_dev, "sq", qidx, ring_size,
+   NICVF_SQ_BASE_ALIGN_BYTES, nic->node);
+   if (rz == NULL) {
+   PMD_INIT_LOG(ERR, "Failed allocate mem for sq hw ring");
+   return -ENOMEM;
+   }
+
+   memset(rz->addr, 0, ring_size);
+
+   sq->phys = rz->phys_addr;
+   sq->desc = rz->addr;
+   sq->qlen_mask = desc_cnt - 1;
+
+   return 0;
+}
+
+static inline void
+nicvf_tx_queue_release_mbufs(struct nicvf_txq *txq)
+{
+   uint32_t head;
+
+   head = txq->head;
+   while (head != txq->tail) {
+   if (txq->txbuffs[head]) {
+   rte_pktmbuf_free_seg(txq->txbuffs[head]);
+   txq->txbuffs[head] = NULL;
+   }
+   head++;
+   head = head & txq->qlen_mask;
+   }
+}
+
+static void
+nicvf_tx_queue_reset(struct nicvf_txq *txq)
+{
+   uint32_t txq_desc_cnt = txq->qlen_mask + 1;
+
+   memset(txq->desc, 0, sizeof(union sq_entry_t) * txq_desc_cnt);
+   memset(txq->txbuffs, 0, sizeof(struct rte_mbuf *) * txq_desc_cnt);
+   txq->tail = 0;
+   txq->head = 0;
+   txq->xmit_bufs = 0;
+}
+
+static void
+nicvf_dev_tx_queue_release(void *sq)
+{
+   struct nicvf_txq *txq;
+
+   PMD_INIT_FUNC_TRACE();
+
+   txq = (struct nicvf_txq *)sq;
+   if (txq) {
+   if (txq->txbuffs != NULL) {
+   nicvf_tx_queue_release_mbufs(txq);
+   rte_free(txq->txbuffs);
+   txq->txbuffs = NULL;
+   }
+   rte_free(txq);
+   }
+}
+
+static int
+nicvf_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
+uint16_t nb_desc, unsigned int socket_id,
+const struct rte_eth_txconf *tx_conf)
+{
+   uint16_t tx_free_thresh;
+   uint8_t is_single_pool;
+   struct nicvf_txq *txq;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   PMD_INIT_FUNC_TRACE();
+
+   /* Socket id check */
+   if (socket_id != (unsigned int)SOCKET_ID_ANY && socket_id != nic->node)
+   PMD_DRV_LOG(WARNING, "socket_id expected %d, configured %d",
+   socket_id, nic->node);
+
+   /* Tx deferred start is not supported */
+   if (tx_conf->tx_deferred_start) {
+   PMD_INIT_LOG(ERR, "Tx deferred start not supported");
+   return -EINVAL;
+   }
+
+   /* Roundup nb_desc to available qsize and validate max number of desc */
+   nb_desc = nicvf_qsize_sq_roundup(nb_desc);
+   if (nb_desc == 0) {
+   PMD_INIT_LOG(ERR, "Value of nb_desc beyond available sq qsize");
+   return -EINVAL;
+   }
+
+   /* Validate tx_free_thresh */
+   tx_free_thresh = (uint16_t)((tx_conf->tx_free_thresh) ?
+   tx_conf->tx_free_thresh :
+   NICVF_DEFAULT_TX_FREE_THRESH);
+
+   if (tx_free_thresh > (nb_desc) ||
+   tx_free_thresh > NICVF_MAX_TX_FREE_THRESH) {
+   PMD_INIT_LOG(ERR,
+   "tx_free_thresh must be less than the number of TX "
+   "descriptors. (tx_free_thresh=%u port=%d "
+   "queue=%d)", (unsigned int)tx_free_thresh,
+   (int)dev->data->port_id, (int)qidx);
+   return -EINVAL;
+   }
+
+   /* Free memory prior to re-allocation if needed. */
+   if (dev->data->tx_queues[qidx] != NULL) {
+   PMD_TX_LOG(DEBUG, "Freeing memory prior to re-allocation %d",
+   qidx);
+   nicvf_dev_tx_queue_release(dev->data->tx_queues[qidx]);
+   dev->data->tx_queues[qidx] = NULL;
+   }
+
+   /* Allocating tx queue data structure */
+   txq = rte_zmalloc_socket("ethdev TX queue", sizeof(struct nicvf_txq),
+   RTE_CACHE_LINE_SIZE, nic->node);
+   if (txq == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate txq=%d", qidx);
+   return 

[dpdk-dev] [PATCH v5 15/25] net/thunderx: add RSS and reta query and update support

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 172 
 1 file changed, 172 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 167149e..1d5bea7 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -168,6 +168,174 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct 
rte_dev_reg_info *regs)
return -ENOTSUP;
 }

+static inline uint64_t
+nicvf_rss_ethdev_to_nic(struct nicvf *nic, uint64_t ethdev_rss)
+{
+   uint64_t nic_rss = 0;
+
+   if (ethdev_rss & ETH_RSS_IPV4)
+   nic_rss |= RSS_IP_ENA;
+
+   if (ethdev_rss & ETH_RSS_IPV6)
+   nic_rss |= RSS_IP_ENA;
+
+   if (ethdev_rss & ETH_RSS_NONFRAG_IPV4_UDP)
+   nic_rss |= (RSS_IP_ENA | RSS_UDP_ENA);
+
+   if (ethdev_rss & ETH_RSS_NONFRAG_IPV4_TCP)
+   nic_rss |= (RSS_IP_ENA | RSS_TCP_ENA);
+
+   if (ethdev_rss & ETH_RSS_NONFRAG_IPV6_UDP)
+   nic_rss |= (RSS_IP_ENA | RSS_UDP_ENA);
+
+   if (ethdev_rss & ETH_RSS_NONFRAG_IPV6_TCP)
+   nic_rss |= (RSS_IP_ENA | RSS_TCP_ENA);
+
+   if (ethdev_rss & ETH_RSS_PORT)
+   nic_rss |= RSS_L2_EXTENDED_HASH_ENA;
+
+   if (nicvf_hw_cap(nic) & NICVF_CAP_TUNNEL_PARSING) {
+   if (ethdev_rss & ETH_RSS_VXLAN)
+   nic_rss |= RSS_TUN_VXLAN_ENA;
+
+   if (ethdev_rss & ETH_RSS_GENEVE)
+   nic_rss |= RSS_TUN_GENEVE_ENA;
+
+   if (ethdev_rss & ETH_RSS_NVGRE)
+   nic_rss |= RSS_TUN_NVGRE_ENA;
+   }
+
+   return nic_rss;
+}
+
+static inline uint64_t
+nicvf_rss_nic_to_ethdev(struct nicvf *nic,  uint64_t nic_rss)
+{
+   uint64_t ethdev_rss = 0;
+
+   if (nic_rss & RSS_IP_ENA)
+   ethdev_rss |= (ETH_RSS_IPV4 | ETH_RSS_IPV6);
+
+   if ((nic_rss & RSS_IP_ENA) && (nic_rss & RSS_TCP_ENA))
+   ethdev_rss |= (ETH_RSS_NONFRAG_IPV4_TCP |
+   ETH_RSS_NONFRAG_IPV6_TCP);
+
+   if ((nic_rss & RSS_IP_ENA) && (nic_rss & RSS_UDP_ENA))
+   ethdev_rss |= (ETH_RSS_NONFRAG_IPV4_UDP |
+   ETH_RSS_NONFRAG_IPV6_UDP);
+
+   if (nic_rss & RSS_L2_EXTENDED_HASH_ENA)
+   ethdev_rss |= ETH_RSS_PORT;
+
+   if (nicvf_hw_cap(nic) & NICVF_CAP_TUNNEL_PARSING) {
+   if (nic_rss & RSS_TUN_VXLAN_ENA)
+   ethdev_rss |= ETH_RSS_VXLAN;
+
+   if (nic_rss & RSS_TUN_GENEVE_ENA)
+   ethdev_rss |= ETH_RSS_GENEVE;
+
+   if (nic_rss & RSS_TUN_NVGRE_ENA)
+   ethdev_rss |= ETH_RSS_NVGRE;
+   }
+   return ethdev_rss;
+}
+
+static int
+nicvf_dev_reta_query(struct rte_eth_dev *dev,
+struct rte_eth_rss_reta_entry64 *reta_conf,
+uint16_t reta_size)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   uint8_t tbl[NIC_MAX_RSS_IDR_TBL_SIZE];
+   int ret, i, j;
+
+   if (reta_size != NIC_MAX_RSS_IDR_TBL_SIZE) {
+   RTE_LOG(ERR, PMD, "The size of hash lookup table configured "
+   "(%d) doesn't match the number hardware can supported "
+   "(%d)", reta_size, NIC_MAX_RSS_IDR_TBL_SIZE);
+   return -EINVAL;
+   }
+
+   ret = nicvf_rss_reta_query(nic, tbl, NIC_MAX_RSS_IDR_TBL_SIZE);
+   if (ret)
+   return ret;
+
+   /* Copy RETA table */
+   for (i = 0; i < (NIC_MAX_RSS_IDR_TBL_SIZE / RTE_RETA_GROUP_SIZE); i++) {
+   for (j = 0; j < RTE_RETA_GROUP_SIZE; j++)
+   if ((reta_conf[i].mask >> j) & 0x01)
+   reta_conf[i].reta[j] = tbl[j];
+   }
+
+   return 0;
+}
+
+static int
+nicvf_dev_reta_update(struct rte_eth_dev *dev,
+ struct rte_eth_rss_reta_entry64 *reta_conf,
+ uint16_t reta_size)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   uint8_t tbl[NIC_MAX_RSS_IDR_TBL_SIZE];
+   int ret, i, j;
+
+   if (reta_size != NIC_MAX_RSS_IDR_TBL_SIZE) {
+   RTE_LOG(ERR, PMD, "The size of hash lookup table configured "
+   "(%d) doesn't match the number hardware can supported "
+   "(%d)", reta_size, NIC_MAX_RSS_IDR_TBL_SIZE);
+   return -EINVAL;
+   }
+
+   ret = nicvf_rss_reta_query(nic, tbl, NIC_MAX_RSS_IDR_TBL_SIZE);
+   if (ret)
+   return ret;
+
+   /* Copy RETA table */
+   for (i = 0; i < (NIC_MAX_RSS_IDR_TBL_SIZE / RTE_RETA_GROUP_SIZE); i++) {
+   for (j = 0; j < RTE_RETA_GROUP_SIZE; j++)
+   if ((reta_conf[i].mask >> j) & 

[dpdk-dev] [PATCH v5 16/25] net/thunderx: add MTU set and promiscuous enable support

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 51 +
 drivers/net/thunderx/nicvf_ethdev.h |  2 ++
 2 files changed, 53 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 1d5bea7..f0e3371 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -144,6 +144,49 @@ nicvf_dev_link_update(struct rte_eth_dev *dev,
 }

 static int
+nicvf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   uint32_t buffsz, frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
+
+   PMD_INIT_FUNC_TRACE();
+
+   if (frame_size > NIC_HW_MAX_FRS)
+   return -EINVAL;
+
+   if (frame_size < NIC_HW_MIN_FRS)
+   return -EINVAL;
+
+   buffsz = dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM;
+
+   /*
+* Refuse mtu that requires the support of scattered packets
+* when this feature has not been enabled before.
+*/
+   if (!dev->data->scattered_rx &&
+   (frame_size + 2 * VLAN_TAG_SIZE > buffsz))
+   return -EINVAL;
+
+   /* check  *   >= max_frame */
+   if (dev->data->scattered_rx &&
+   (frame_size + 2 * VLAN_TAG_SIZE > buffsz * NIC_HW_MAX_SEGS))
+   return -EINVAL;
+
+   if (frame_size > ETHER_MAX_LEN)
+   dev->data->dev_conf.rxmode.jumbo_frame = 1;
+   else
+   dev->data->dev_conf.rxmode.jumbo_frame = 0;
+
+   if (nicvf_mbox_update_hw_max_frs(nic, frame_size))
+   return -EINVAL;
+
+   /* Update max frame size */
+   dev->data->dev_conf.rxmode.max_rx_pkt_len = (uint32_t)frame_size;
+   nic->mtu = mtu;
+   return 0;
+}
+
+static int
 nicvf_dev_get_reg_length(struct rte_eth_dev *dev  __rte_unused)
 {
return nicvf_reg_get_count();
@@ -168,6 +211,12 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct 
rte_dev_reg_info *regs)
return -ENOTSUP;
 }

+/* Promiscuous mode enabled by default in LMAC to VF 1:1 map configuration */
+static void
+nicvf_dev_promisc_enable(struct rte_eth_dev *dev __rte_unused)
+{
+}
+
 static inline uint64_t
 nicvf_rss_ethdev_to_nic(struct nicvf *nic, uint64_t ethdev_rss)
 {
@@ -768,7 +817,9 @@ nicvf_dev_configure(struct rte_eth_dev *dev)
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
.dev_configure= nicvf_dev_configure,
.link_update  = nicvf_dev_link_update,
+   .promiscuous_enable   = nicvf_dev_promisc_enable,
.dev_infos_get= nicvf_dev_info_get,
+   .mtu_set  = nicvf_dev_set_mtu,
.reta_update  = nicvf_dev_reta_update,
.reta_query   = nicvf_dev_reta_query,
.rss_hash_update  = nicvf_dev_rss_hash_update,
diff --git a/drivers/net/thunderx/nicvf_ethdev.h 
b/drivers/net/thunderx/nicvf_ethdev.h
index afb875a..b1af468 100644
--- a/drivers/net/thunderx/nicvf_ethdev.h
+++ b/drivers/net/thunderx/nicvf_ethdev.h
@@ -62,6 +62,8 @@
 #define NICVF_MAX_RX_FREE_THRESH1024
 #define NICVF_MAX_TX_FREE_THRESH1024

+#define VLAN_TAG_SIZE   4  /* 802.3ac tag */
+
 static inline struct nicvf *
 nicvf_pmd_priv(struct rte_eth_dev *eth_dev)
 {
-- 
2.5.5



[dpdk-dev] [PATCH v5 17/25] net/thunderx: add stats support

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.c | 66 +
 1 file changed, 66 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index f0e3371..19ad85a 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -211,6 +211,70 @@ nicvf_dev_get_regs(struct rte_eth_dev *dev, struct 
rte_dev_reg_info *regs)
return -ENOTSUP;
 }

+static void
+nicvf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+   uint16_t qidx;
+   struct nicvf_hw_rx_qstats rx_qstats;
+   struct nicvf_hw_tx_qstats tx_qstats;
+   struct nicvf_hw_stats port_stats;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   /* Reading per RX ring stats */
+   for (qidx = 0; qidx < dev->data->nb_rx_queues; qidx++) {
+   if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS)
+   break;
+
+   nicvf_hw_get_rx_qstats(nic, _qstats, qidx);
+   stats->q_ibytes[qidx] = rx_qstats.q_rx_bytes;
+   stats->q_ipackets[qidx] = rx_qstats.q_rx_packets;
+   }
+
+   /* Reading per TX ring stats */
+   for (qidx = 0; qidx < dev->data->nb_tx_queues; qidx++) {
+   if (qidx == RTE_ETHDEV_QUEUE_STAT_CNTRS)
+   break;
+
+   nicvf_hw_get_tx_qstats(nic, _qstats, qidx);
+   stats->q_obytes[qidx] = tx_qstats.q_tx_bytes;
+   stats->q_opackets[qidx] = tx_qstats.q_tx_packets;
+   }
+
+   nicvf_hw_get_stats(nic, _stats);
+   stats->ibytes = port_stats.rx_bytes;
+   stats->ipackets = port_stats.rx_ucast_frames;
+   stats->ipackets += port_stats.rx_bcast_frames;
+   stats->ipackets += port_stats.rx_mcast_frames;
+   stats->ierrors = port_stats.rx_l2_errors;
+   stats->imissed = port_stats.rx_drop_red;
+   stats->imissed += port_stats.rx_drop_overrun;
+   stats->imissed += port_stats.rx_drop_bcast;
+   stats->imissed += port_stats.rx_drop_mcast;
+   stats->imissed += port_stats.rx_drop_l3_bcast;
+   stats->imissed += port_stats.rx_drop_l3_mcast;
+
+   stats->obytes = port_stats.tx_bytes_ok;
+   stats->opackets = port_stats.tx_ucast_frames_ok;
+   stats->opackets += port_stats.tx_bcast_frames_ok;
+   stats->opackets += port_stats.tx_mcast_frames_ok;
+   stats->oerrors = port_stats.tx_drops;
+}
+
+static void
+nicvf_dev_stats_reset(struct rte_eth_dev *dev)
+{
+   int i;
+   uint16_t rxqs = 0, txqs = 0;
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
+   rxqs |= (0x3 << (i * 2));
+   for (i = 0; i < dev->data->nb_tx_queues; i++)
+   txqs |= (0x3 << (i * 2));
+
+   nicvf_mbox_reset_stat_counters(nic, 0x3FFF, 0x1F, rxqs, txqs);
+}
+
 /* Promiscuous mode enabled by default in LMAC to VF 1:1 map configuration */
 static void
 nicvf_dev_promisc_enable(struct rte_eth_dev *dev __rte_unused)
@@ -817,6 +881,8 @@ nicvf_dev_configure(struct rte_eth_dev *dev)
 static const struct eth_dev_ops nicvf_eth_dev_ops = {
.dev_configure= nicvf_dev_configure,
.link_update  = nicvf_dev_link_update,
+   .stats_get= nicvf_dev_stats_get,
+   .stats_reset  = nicvf_dev_stats_reset,
.promiscuous_enable   = nicvf_dev_promisc_enable,
.dev_infos_get= nicvf_dev_info_get,
.mtu_set  = nicvf_dev_set_mtu,
-- 
2.5.5



[dpdk-dev] [PATCH v5 18/25] net/thunderx: add single and multi segment Tx functions

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/Makefile   |   2 +
 drivers/net/thunderx/nicvf_ethdev.c |   5 +-
 drivers/net/thunderx/nicvf_rxtx.c   | 255 
 drivers/net/thunderx/nicvf_rxtx.h   |  93 +
 4 files changed, 354 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/thunderx/nicvf_rxtx.c
 create mode 100644 drivers/net/thunderx/nicvf_rxtx.h

diff --git a/drivers/net/thunderx/Makefile b/drivers/net/thunderx/Makefile
index eb9f100..9079b5b 100644
--- a/drivers/net/thunderx/Makefile
+++ b/drivers/net/thunderx/Makefile
@@ -51,10 +51,12 @@ VPATH += $(SRCDIR)/base
 #
 # all source are stored in SRCS-y
 #
+SRCS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += nicvf_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += nicvf_hw.c
 SRCS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += nicvf_mbox.c
 SRCS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += nicvf_ethdev.c

+CFLAGS_nicvf_rxtx.o += -fno-prefetch-loop-arrays -Ofast

 # this lib depends upon:
 DEPDIRS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += lib/librte_eal 
lib/librte_ether
diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 19ad85a..15f5cfc 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -66,7 +66,7 @@
 #include "base/nicvf_plat.h"

 #include "nicvf_ethdev.h"
-
+#include "nicvf_rxtx.h"
 #include "nicvf_logs.h"

 static inline int
@@ -617,6 +617,9 @@ nicvf_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
qidx,
(tx_conf->tx_free_thresh == NICVF_DEFAULT_TX_FREE_THRESH ?
NICVF_TX_FREE_MPOOL_THRESH :
tx_conf->tx_free_thresh);
+   txq->pool_free = nicvf_multi_pool_free_xmited_buffers;
+   } else {
+   txq->pool_free = nicvf_single_pool_free_xmited_buffers;
}

/* Allocate software ring */
diff --git a/drivers/net/thunderx/nicvf_rxtx.c 
b/drivers/net/thunderx/nicvf_rxtx.c
new file mode 100644
index 000..88a5152
--- /dev/null
+++ b/drivers/net/thunderx/nicvf_rxtx.c
@@ -0,0 +1,255 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright (C) Cavium networks Ltd. 2016.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Cavium networks nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   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
+ *   OWNER 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 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "base/nicvf_plat.h"
+
+#include "nicvf_ethdev.h"
+#include "nicvf_rxtx.h"
+#include "nicvf_logs.h"
+
+static inline void __hot
+fill_sq_desc_header(union sq_entry_t *entry, struct rte_mbuf *pkt)
+{
+   /* Local variable sqe to avoid read from sq desc memory*/
+   union sq_entry_t sqe;
+   uint64_t ol_flags;
+
+   /* Fill SQ header descriptor */
+   sqe.buff[0] = 0;
+   sqe.hdr.subdesc_type = SQ_DESC_TYPE_HEADER;
+   /* Number of sub-descriptors following this one */
+   sqe.hdr.subdesc_cnt = pkt->nb_segs;
+   sqe.hdr.tot_len = pkt->pkt_len;
+
+   ol_flags = pkt->ol_flags & NICVF_TX_OFFLOAD_MASK;
+   if (unlikely(ol_flags)) {
+   /* L4 cksum */
+   if (ol_flags & PKT_TX_TCP_CKSUM)
+   sqe.hdr.csum_l4 = SEND_L4_CSUM_TCP;
+   else if (ol_flags 

[dpdk-dev] [PATCH v5 19/25] net/thunderx: add single and multi segment Rx functions

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
Reviewed-by: Ferruh Yigit 
---
 drivers/net/thunderx/nicvf_ethdev.h |  33 
 drivers/net/thunderx/nicvf_rxtx.c   | 317 
 drivers/net/thunderx/nicvf_rxtx.h   |   5 +
 3 files changed, 355 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.h 
b/drivers/net/thunderx/nicvf_ethdev.h
index b1af468..59fa19c 100644
--- a/drivers/net/thunderx/nicvf_ethdev.h
+++ b/drivers/net/thunderx/nicvf_ethdev.h
@@ -70,4 +70,37 @@ nicvf_pmd_priv(struct rte_eth_dev *eth_dev)
return eth_dev->data->dev_private;
 }

+static inline uint64_t
+nicvf_mempool_phy_offset(struct rte_mempool *mp)
+{
+   struct rte_mempool_memhdr *hdr;
+
+   hdr = STAILQ_FIRST(>mem_list);
+   assert(hdr != NULL);
+   return (uint64_t)((uintptr_t)hdr->addr - hdr->phys_addr);
+}
+
+static inline uint16_t
+nicvf_mbuff_meta_length(struct rte_mbuf *mbuf)
+{
+   return (uint16_t)((uintptr_t)mbuf->buf_addr - (uintptr_t)mbuf);
+}
+
+/*
+ * Simple phy2virt functions assuming mbufs are in a single huge page
+ * V = P + offset
+ * P = V - offset
+ */
+static inline uintptr_t
+nicvf_mbuff_phy2virt(phys_addr_t phy, uint64_t mbuf_phys_off)
+{
+   return (uintptr_t)(phy + mbuf_phys_off);
+}
+
+static inline uintptr_t
+nicvf_mbuff_virt2phy(uintptr_t virt, uint64_t mbuf_phys_off)
+{
+   return (phys_addr_t)(virt - mbuf_phys_off);
+}
+
 #endif /* __THUNDERX_NICVF_ETHDEV_H__  */
diff --git a/drivers/net/thunderx/nicvf_rxtx.c 
b/drivers/net/thunderx/nicvf_rxtx.c
index 88a5152..fed0859 100644
--- a/drivers/net/thunderx/nicvf_rxtx.c
+++ b/drivers/net/thunderx/nicvf_rxtx.c
@@ -253,3 +253,320 @@ nicvf_xmit_pkts_multiseg(void *tx_queue, struct rte_mbuf 
**tx_pkts,
nicvf_addr_write(sq->sq_door, used_desc);
return nb_pkts;
 }
+
+static const uint32_t ptype_table[16][16] __rte_cache_aligned = {
+   [L3_NONE][L4_NONE] = RTE_PTYPE_UNKNOWN,
+   [L3_NONE][L4_IPSEC_ESP] = RTE_PTYPE_UNKNOWN,
+   [L3_NONE][L4_IPFRAG] = RTE_PTYPE_L4_FRAG,
+   [L3_NONE][L4_IPCOMP] = RTE_PTYPE_UNKNOWN,
+   [L3_NONE][L4_TCP] = RTE_PTYPE_L4_TCP,
+   [L3_NONE][L4_UDP_PASS1] = RTE_PTYPE_L4_UDP,
+   [L3_NONE][L4_GRE] = RTE_PTYPE_TUNNEL_GRE,
+   [L3_NONE][L4_UDP_PASS2] = RTE_PTYPE_L4_UDP,
+   [L3_NONE][L4_UDP_GENEVE] = RTE_PTYPE_TUNNEL_GENEVE,
+   [L3_NONE][L4_UDP_VXLAN] = RTE_PTYPE_TUNNEL_VXLAN,
+   [L3_NONE][L4_NVGRE] = RTE_PTYPE_TUNNEL_NVGRE,
+
+   [L3_IPV4][L4_NONE] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_UNKNOWN,
+   [L3_IPV4][L4_IPSEC_ESP] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L3_IPV4,
+   [L3_IPV4][L4_IPFRAG] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_FRAG,
+   [L3_IPV4][L4_IPCOMP] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_UNKNOWN,
+   [L3_IPV4][L4_TCP] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_TCP,
+   [L3_IPV4][L4_UDP_PASS1] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP,
+   [L3_IPV4][L4_GRE] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_GRE,
+   [L3_IPV4][L4_UDP_PASS2] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_L4_UDP,
+   [L3_IPV4][L4_UDP_GENEVE] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_GENEVE,
+   [L3_IPV4][L4_UDP_VXLAN] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_VXLAN,
+   [L3_IPV4][L4_NVGRE] = RTE_PTYPE_L3_IPV4 | RTE_PTYPE_TUNNEL_NVGRE,
+
+   [L3_IPV4_OPT][L4_NONE] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_UNKNOWN,
+   [L3_IPV4_OPT][L4_IPSEC_ESP] =  RTE_PTYPE_L3_IPV4_EXT |
+   RTE_PTYPE_L3_IPV4,
+   [L3_IPV4_OPT][L4_IPFRAG] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_FRAG,
+   [L3_IPV4_OPT][L4_IPCOMP] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_UNKNOWN,
+   [L3_IPV4_OPT][L4_TCP] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_TCP,
+   [L3_IPV4_OPT][L4_UDP_PASS1] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_UDP,
+   [L3_IPV4_OPT][L4_GRE] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_TUNNEL_GRE,
+   [L3_IPV4_OPT][L4_UDP_PASS2] = RTE_PTYPE_L3_IPV4_EXT | RTE_PTYPE_L4_UDP,
+   [L3_IPV4_OPT][L4_UDP_GENEVE] = RTE_PTYPE_L3_IPV4_EXT |
+   RTE_PTYPE_TUNNEL_GENEVE,
+   [L3_IPV4_OPT][L4_UDP_VXLAN] = RTE_PTYPE_L3_IPV4_EXT |
+   RTE_PTYPE_TUNNEL_VXLAN,
+   [L3_IPV4_OPT][L4_NVGRE] = RTE_PTYPE_L3_IPV4_EXT |
+   RTE_PTYPE_TUNNEL_NVGRE,
+
+   [L3_IPV6][L4_NONE] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_UNKNOWN,
+   [L3_IPV6][L4_IPSEC_ESP] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L3_IPV4,
+   [L3_IPV6][L4_IPFRAG] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_FRAG,
+   [L3_IPV6][L4_IPCOMP] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_UNKNOWN,
+   [L3_IPV6][L4_TCP] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_TCP,
+   [L3_IPV6][L4_UDP_PASS1] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP,
+   [L3_IPV6][L4_GRE] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_TUNNEL_GRE,
+   [L3_IPV6][L4_UDP_PASS2] = RTE_PTYPE_L3_IPV6 | RTE_PTYPE_L4_UDP,
+   

[dpdk-dev] [PATCH v5 20/25] net/thunderx: implement supported ptype get and Rx queue count

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/nicvf_ethdev.c | 41 +
 drivers/net/thunderx/nicvf_rxtx.c   |  9 
 drivers/net/thunderx/nicvf_rxtx.h   |  2 ++
 3 files changed, 52 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 15f5cfc..8b8d9d9 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -260,6 +260,45 @@ nicvf_dev_stats_get(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)
stats->oerrors = port_stats.tx_drops;
 }

+static const uint32_t *
+nicvf_dev_supported_ptypes_get(struct rte_eth_dev *dev)
+{
+   size_t copied;
+   static uint32_t ptypes[32];
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   static const uint32_t ptypes_pass1[] = {
+   RTE_PTYPE_L3_IPV4,
+   RTE_PTYPE_L3_IPV4_EXT,
+   RTE_PTYPE_L3_IPV6,
+   RTE_PTYPE_L3_IPV6_EXT,
+   RTE_PTYPE_L4_TCP,
+   RTE_PTYPE_L4_UDP,
+   RTE_PTYPE_L4_FRAG,
+   };
+   static const uint32_t ptypes_pass2[] = {
+   RTE_PTYPE_TUNNEL_GRE,
+   RTE_PTYPE_TUNNEL_GENEVE,
+   RTE_PTYPE_TUNNEL_VXLAN,
+   RTE_PTYPE_TUNNEL_NVGRE,
+   };
+   static const uint32_t ptypes_end = RTE_PTYPE_UNKNOWN;
+
+   copied = sizeof(ptypes_pass1);
+   memcpy(ptypes, ptypes_pass1, copied);
+   if (nicvf_hw_version(nic) == NICVF_PASS2) {
+   memcpy((char *)ptypes + copied, ptypes_pass2,
+   sizeof(ptypes_pass2));
+   copied += sizeof(ptypes_pass2);
+   }
+
+   memcpy((char *)ptypes + copied, _end, sizeof(ptypes_end));
+   if (dev->rx_pkt_burst == nicvf_recv_pkts ||
+   dev->rx_pkt_burst == nicvf_recv_pkts_multiseg)
+   return ptypes;
+
+   return NULL;
+}
+
 static void
 nicvf_dev_stats_reset(struct rte_eth_dev *dev)
 {
@@ -888,6 +927,7 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = {
.stats_reset  = nicvf_dev_stats_reset,
.promiscuous_enable   = nicvf_dev_promisc_enable,
.dev_infos_get= nicvf_dev_info_get,
+   .dev_supported_ptypes_get = nicvf_dev_supported_ptypes_get,
.mtu_set  = nicvf_dev_set_mtu,
.reta_update  = nicvf_dev_reta_update,
.reta_query   = nicvf_dev_reta_query,
@@ -895,6 +935,7 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = {
.rss_hash_conf_get= nicvf_dev_rss_hash_conf_get,
.rx_queue_setup   = nicvf_dev_rx_queue_setup,
.rx_queue_release = nicvf_dev_rx_queue_release,
+   .rx_queue_count   = nicvf_dev_rx_queue_count,
.tx_queue_setup   = nicvf_dev_tx_queue_setup,
.tx_queue_release = nicvf_dev_tx_queue_release,
.get_reg_length   = nicvf_dev_get_reg_length,
diff --git a/drivers/net/thunderx/nicvf_rxtx.c 
b/drivers/net/thunderx/nicvf_rxtx.c
index fed0859..1c6d6a8 100644
--- a/drivers/net/thunderx/nicvf_rxtx.c
+++ b/drivers/net/thunderx/nicvf_rxtx.c
@@ -570,3 +570,12 @@ nicvf_recv_pkts_multiseg(void *rx_queue, struct rte_mbuf 
**rx_pkts,

return to_process;
 }
+
+uint32_t
+nicvf_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx)
+{
+   struct nicvf_rxq *rxq;
+
+   rxq = dev->data->rx_queues[queue_idx];
+   return nicvf_addr_read(rxq->cq_status) & NICVF_CQ_CQE_COUNT_MASK;
+}
diff --git a/drivers/net/thunderx/nicvf_rxtx.h 
b/drivers/net/thunderx/nicvf_rxtx.h
index d2ca2c9..ded87f3 100644
--- a/drivers/net/thunderx/nicvf_rxtx.h
+++ b/drivers/net/thunderx/nicvf_rxtx.h
@@ -84,6 +84,8 @@ fill_sq_desc_gather(union sq_entry_t *entry, struct rte_mbuf 
*pkt)
 }
 #endif

+uint32_t nicvf_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx);
+
 uint16_t nicvf_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts, uint16_t pkts);
 uint16_t nicvf_recv_pkts_multiseg(void *rx_queue, struct rte_mbuf **rx_pkts,
  uint16_t nb_pkts);
-- 
2.5.5



[dpdk-dev] [PATCH v5 21/25] net/thunderx: add Rx queue start and stop support

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/nicvf_ethdev.c | 167 
 drivers/net/thunderx/nicvf_rxtx.c   |  18 
 drivers/net/thunderx/nicvf_rxtx.h   |   1 +
 3 files changed, 186 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 8b8d9d9..7a58cb3 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -562,6 +562,54 @@ nicvf_tx_queue_reset(struct nicvf_txq *txq)
txq->xmit_bufs = 0;
 }

+
+static inline int
+nicvf_configure_cpi(struct rte_eth_dev *dev)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   uint16_t qidx, qcnt;
+   int ret;
+
+   /* Count started rx queues */
+   for (qidx = qcnt = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++)
+   if (dev->data->rx_queue_state[qidx] ==
+   RTE_ETH_QUEUE_STATE_STARTED)
+   qcnt++;
+
+   nic->cpi_alg = CPI_ALG_NONE;
+   ret = nicvf_mbox_config_cpi(nic, qcnt);
+   if (ret)
+   PMD_INIT_LOG(ERR, "Failed to configure CPI %d", ret);
+
+   return ret;
+}
+
+static int
+nicvf_configure_rss_reta(struct rte_eth_dev *dev)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   unsigned int idx, qmap_size;
+   uint8_t qmap[RTE_MAX_QUEUES_PER_PORT];
+   uint8_t default_reta[NIC_MAX_RSS_IDR_TBL_SIZE];
+
+   if (nic->cpi_alg != CPI_ALG_NONE)
+   return -EINVAL;
+
+   /* Prepare queue map */
+   for (idx = 0, qmap_size = 0; idx < dev->data->nb_rx_queues; idx++) {
+   if (dev->data->rx_queue_state[idx] ==
+   RTE_ETH_QUEUE_STATE_STARTED)
+   qmap[qmap_size++] = idx;
+   }
+
+   /* Update default RSS RETA */
+   for (idx = 0; idx < NIC_MAX_RSS_IDR_TBL_SIZE; idx++)
+   default_reta[idx] = qmap[idx % qmap_size];
+
+   return nicvf_rss_reta_update(nic, default_reta,
+NIC_MAX_RSS_IDR_TBL_SIZE);
+}
+
 static void
 nicvf_dev_tx_queue_release(void *sq)
 {
@@ -687,6 +735,33 @@ nicvf_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
qidx,
return 0;
 }

+static inline void
+nicvf_rx_queue_release_mbufs(struct nicvf_rxq *rxq)
+{
+   uint32_t rxq_cnt;
+   uint32_t nb_pkts, released_pkts = 0;
+   uint32_t refill_cnt = 0;
+   struct rte_eth_dev *dev = rxq->nic->eth_dev;
+   struct rte_mbuf *rx_pkts[NICVF_MAX_RX_FREE_THRESH];
+
+   if (dev->rx_pkt_burst == NULL)
+   return;
+
+   while ((rxq_cnt = nicvf_dev_rx_queue_count(dev, rxq->queue_id))) {
+   nb_pkts = dev->rx_pkt_burst(rxq, rx_pkts,
+   NICVF_MAX_RX_FREE_THRESH);
+   PMD_DRV_LOG(INFO, "nb_pkts=%d  rxq_cnt=%d", nb_pkts, rxq_cnt);
+   while (nb_pkts) {
+   rte_pktmbuf_free_seg(rx_pkts[--nb_pkts]);
+   released_pkts++;
+   }
+   }
+
+   refill_cnt += nicvf_dev_rbdr_refill(dev, rxq->queue_id);
+   PMD_DRV_LOG(INFO, "free_cnt=%d  refill_cnt=%d",
+   released_pkts, refill_cnt);
+}
+
 static void
 nicvf_rx_queue_reset(struct nicvf_rxq *rxq)
 {
@@ -695,6 +770,69 @@ nicvf_rx_queue_reset(struct nicvf_rxq *rxq)
rxq->recv_buffers = 0;
 }

+static inline int
+nicvf_start_rx_queue(struct rte_eth_dev *dev, uint16_t qidx)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   struct nicvf_rxq *rxq;
+   int ret;
+
+   if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED)
+   return 0;
+
+   /* Update rbdr pointer to all rxq */
+   rxq = dev->data->rx_queues[qidx];
+   rxq->shared_rbdr = nic->rbdr;
+
+   ret = nicvf_qset_rq_config(nic, qidx, rxq);
+   if (ret) {
+   PMD_INIT_LOG(ERR, "Failed to configure rq %d %d", qidx, ret);
+   goto config_rq_error;
+   }
+   ret = nicvf_qset_cq_config(nic, qidx, rxq);
+   if (ret) {
+   PMD_INIT_LOG(ERR, "Failed to configure cq %d %d", qidx, ret);
+   goto config_cq_error;
+   }
+
+   dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+   return 0;
+
+config_cq_error:
+   nicvf_qset_cq_reclaim(nic, qidx);
+config_rq_error:
+   nicvf_qset_rq_reclaim(nic, qidx);
+   return ret;
+}
+
+static inline int
+nicvf_stop_rx_queue(struct rte_eth_dev *dev, uint16_t qidx)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   struct nicvf_rxq *rxq;
+   int ret, other_error;
+
+   if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED)
+   return 0;
+
+   ret = nicvf_qset_rq_reclaim(nic, qidx);
+   if (ret)
+   PMD_INIT_LOG(ERR, "Failed to reclaim rq %d 

[dpdk-dev] [PATCH v5 22/25] net/thunderx: add Tx queue start and stop support

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/nicvf_ethdev.c | 59 +
 1 file changed, 59 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 7a58cb3..3c88290 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -562,6 +562,51 @@ nicvf_tx_queue_reset(struct nicvf_txq *txq)
txq->xmit_bufs = 0;
 }

+static inline int
+nicvf_start_tx_queue(struct rte_eth_dev *dev, uint16_t qidx)
+{
+   struct nicvf_txq *txq;
+   int ret;
+
+   if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED)
+   return 0;
+
+   txq = dev->data->tx_queues[qidx];
+   txq->pool = NULL;
+   ret = nicvf_qset_sq_config(nicvf_pmd_priv(dev), qidx, txq);
+   if (ret) {
+   PMD_INIT_LOG(ERR, "Failed to configure sq %d %d", qidx, ret);
+   goto config_sq_error;
+   }
+
+   dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED;
+   return ret;
+
+config_sq_error:
+   nicvf_qset_sq_reclaim(nicvf_pmd_priv(dev), qidx);
+   return ret;
+}
+
+static inline int
+nicvf_stop_tx_queue(struct rte_eth_dev *dev, uint16_t qidx)
+{
+   struct nicvf_txq *txq;
+   int ret;
+
+   if (dev->data->tx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED)
+   return 0;
+
+   ret = nicvf_qset_sq_reclaim(nicvf_pmd_priv(dev), qidx);
+   if (ret)
+   PMD_INIT_LOG(ERR, "Failed to reclaim sq %d %d", qidx, ret);
+
+   txq = dev->data->tx_queues[qidx];
+   nicvf_tx_queue_release_mbufs(txq);
+   nicvf_tx_queue_reset(txq);
+
+   dev->data->tx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED;
+   return ret;
+}

 static inline int
 nicvf_configure_cpi(struct rte_eth_dev *dev)
@@ -872,6 +917,18 @@ nicvf_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t 
qidx)
 }

 static int
+nicvf_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t qidx)
+{
+   return nicvf_start_tx_queue(dev, qidx);
+}
+
+static int
+nicvf_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx)
+{
+   return nicvf_stop_tx_queue(dev, qidx);
+}
+
+static int
 nicvf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
 uint16_t nb_desc, unsigned int socket_id,
 const struct rte_eth_rxconf *rx_conf,
@@ -1100,6 +1157,8 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = {
.rss_hash_conf_get= nicvf_dev_rss_hash_conf_get,
.rx_queue_start   = nicvf_dev_rx_queue_start,
.rx_queue_stop= nicvf_dev_rx_queue_stop,
+   .tx_queue_start   = nicvf_dev_tx_queue_start,
+   .tx_queue_stop= nicvf_dev_tx_queue_stop,
.rx_queue_setup   = nicvf_dev_rx_queue_setup,
.rx_queue_release = nicvf_dev_rx_queue_release,
.rx_queue_count   = nicvf_dev_rx_queue_count,
-- 
2.5.5



[dpdk-dev] [PATCH v5 23/25] net/thunderx: add device start, stop and close support

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
Signed-off-by: Kamil Rytarowski 
Signed-off-by: Zyta Szpak 
Signed-off-by: Slawomir Rosek 
Signed-off-by: Radoslaw Biernacki 
---
 drivers/net/thunderx/nicvf_ethdev.c | 467 
 1 file changed, 467 insertions(+)

diff --git a/drivers/net/thunderx/nicvf_ethdev.c 
b/drivers/net/thunderx/nicvf_ethdev.c
index 3c88290..7d545f9 100644
--- a/drivers/net/thunderx/nicvf_ethdev.c
+++ b/drivers/net/thunderx/nicvf_ethdev.c
@@ -69,6 +69,8 @@
 #include "nicvf_rxtx.h"
 #include "nicvf_logs.h"

+static void nicvf_dev_stop(struct rte_eth_dev *dev);
+
 static inline int
 nicvf_atomic_write_link_status(struct rte_eth_dev *dev,
   struct rte_eth_link *link)
@@ -534,6 +536,82 @@ nicvf_qset_sq_alloc(struct nicvf *nic,  struct nicvf_txq 
*sq, uint16_t qidx,
return 0;
 }

+static int
+nicvf_qset_rbdr_alloc(struct nicvf *nic, uint32_t desc_cnt, uint32_t buffsz)
+{
+   struct nicvf_rbdr *rbdr;
+   const struct rte_memzone *rz;
+   uint32_t ring_size;
+
+   assert(nic->rbdr == NULL);
+   rbdr = rte_zmalloc_socket("rbdr", sizeof(struct nicvf_rbdr),
+ RTE_CACHE_LINE_SIZE, nic->node);
+   if (rbdr == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate mem for rbdr");
+   return -ENOMEM;
+   }
+
+   ring_size = sizeof(struct rbdr_entry_t) * desc_cnt;
+   rz = rte_eth_dma_zone_reserve(nic->eth_dev, "rbdr", 0, ring_size,
+  NICVF_RBDR_BASE_ALIGN_BYTES, nic->node);
+   if (rz == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate mem for rbdr desc ring");
+   return -ENOMEM;
+   }
+
+   memset(rz->addr, 0, ring_size);
+
+   rbdr->phys = rz->phys_addr;
+   rbdr->tail = 0;
+   rbdr->next_tail = 0;
+   rbdr->desc = rz->addr;
+   rbdr->buffsz = buffsz;
+   rbdr->qlen_mask = desc_cnt - 1;
+   rbdr->rbdr_status =
+   nicvf_qset_base(nic, 0) + NIC_QSET_RBDR_0_1_STATUS0;
+   rbdr->rbdr_door =
+   nicvf_qset_base(nic, 0) + NIC_QSET_RBDR_0_1_DOOR;
+
+   nic->rbdr = rbdr;
+   return 0;
+}
+
+static void
+nicvf_rbdr_release_mbuf(struct nicvf *nic, nicvf_phys_addr_t phy)
+{
+   uint16_t qidx;
+   void *obj;
+   struct nicvf_rxq *rxq;
+
+   for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
+   rxq = nic->eth_dev->data->rx_queues[qidx];
+   if (rxq->precharge_cnt) {
+   obj = (void *)nicvf_mbuff_phy2virt(phy,
+  rxq->mbuf_phys_off);
+   rte_mempool_put(rxq->pool, obj);
+   rxq->precharge_cnt--;
+   break;
+   }
+   }
+}
+
+static inline void
+nicvf_rbdr_release_mbufs(struct nicvf *nic)
+{
+   uint32_t qlen_mask, head;
+   struct rbdr_entry_t *entry;
+   struct nicvf_rbdr *rbdr = nic->rbdr;
+
+   qlen_mask = rbdr->qlen_mask;
+   head = rbdr->head;
+   while (head != rbdr->tail) {
+   entry = rbdr->desc + head;
+   nicvf_rbdr_release_mbuf(nic, entry->full_addr);
+   head++;
+   head = head & qlen_mask;
+   }
+}
+
 static inline void
 nicvf_tx_queue_release_mbufs(struct nicvf_txq *txq)
 {
@@ -629,6 +707,31 @@ nicvf_configure_cpi(struct rte_eth_dev *dev)
return ret;
 }

+static inline int
+nicvf_configure_rss(struct rte_eth_dev *dev)
+{
+   struct nicvf *nic = nicvf_pmd_priv(dev);
+   uint64_t rsshf;
+   int ret = -EINVAL;
+
+   rsshf = nicvf_rss_ethdev_to_nic(nic,
+   dev->data->dev_conf.rx_adv_conf.rss_conf.rss_hf);
+   PMD_DRV_LOG(INFO, "mode=%d rx_queues=%d loopback=%d rsshf=0x%" PRIx64,
+   dev->data->dev_conf.rxmode.mq_mode,
+   nic->eth_dev->data->nb_rx_queues,
+   nic->eth_dev->data->dev_conf.lpbk_mode, rsshf);
+
+   if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_NONE)
+   ret = nicvf_rss_term(nic);
+   else if (dev->data->dev_conf.rxmode.mq_mode == ETH_MQ_RX_RSS)
+   ret = nicvf_rss_config(nic,
+  nic->eth_dev->data->nb_rx_queues, rsshf);
+   if (ret)
+   PMD_INIT_LOG(ERR, "Failed to configure RSS %d", ret);
+
+   return ret;
+}
+
 static int
 nicvf_configure_rss_reta(struct rte_eth_dev *dev)
 {
@@ -673,6 +776,48 @@ nicvf_dev_tx_queue_release(void *sq)
}
 }

+static void
+nicvf_set_tx_function(struct rte_eth_dev *dev)
+{
+   struct nicvf_txq *txq;
+   size_t i;
+   bool multiseg = false;
+
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   if ((txq->txq_flags & ETH_TXQ_FLAGS_NOMULTSEGS) == 0) {
+   multiseg = true;
+   

[dpdk-dev] [PATCH v5 24/25] net/thunderx: updated driver documentation and release notes

2016-06-15 Thread Jerin Jacob
Updated doc/guides/nics/overview.rst, doc/guides/nics/thunderx.rst
and release notes

Changed "*" to "P" in overview.rst to capture the partially supported
feature as "*" creating alignment issues with Sphinx table

Signed-off-by: Jerin Jacob 
Signed-off-by: Slawomir Rosek 
Acked-by: John McNamara 
---
 doc/guides/nics/index.rst  |   1 +
 doc/guides/nics/overview.rst   |  96 -
 doc/guides/nics/thunderx.rst   | 354 +
 doc/guides/rel_notes/release_16_07.rst |   1 +
 4 files changed, 404 insertions(+), 48 deletions(-)
 create mode 100644 doc/guides/nics/thunderx.rst

diff --git a/doc/guides/nics/index.rst b/doc/guides/nics/index.rst
index 0b13698..ddf75f4 100644
--- a/doc/guides/nics/index.rst
+++ b/doc/guides/nics/index.rst
@@ -50,6 +50,7 @@ Network Interface Controller Drivers
 nfp
 qede
 szedata2
+thunderx
 virtio
 vhost
 vmxnet3
diff --git a/doc/guides/nics/overview.rst b/doc/guides/nics/overview.rst
index 0bd8fae..df28510 100644
--- a/doc/guides/nics/overview.rst
+++ b/doc/guides/nics/overview.rst
@@ -74,40 +74,40 @@ Most of these differences are summarized below.

 .. table:: Features availability in networking drivers

-    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = = = = = = = =
-   Feature  a b b b c e e e i i i i i i i i i i f f f f m m m n n 
p q q r s v v v v x
-f n n o x 1 n n 4 4 4 4 g g x x x x m m m m l l p f u 
c e e i z h i i m e
-p x x n g 0 a i 0 0 0 0 b b g g g g 1 1 1 1 x x i p l 
a d d n e o r r x n
-a 2 2 d b 0   c e e e e   v b b b b 0 0 0 0 4 5 p   l 
p e e g d s t t n v
-c x x i e 0   . v v   f e e e e k k k k e  
   v   a t i i e i
-k   v n   . f f   . v v   . v v
   f   t   o o t r
-e   f g   .   .   . f f   . f f
   a . 3 t
-t v   v   v   v   v   v
   2 v
-  e   e   e   e   e   e
 e
-  c   c   c   c   c   c
 c
-    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = = = = = = = =
+    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = = = = = = = = =
+   Feature  a b b b c e e e i i i i i i i i i i f f f f m m m n n 
p q q r s t v v v v x
+f n n o x 1 n n 4 4 4 4 g g x x x x m m m m l l p f u 
c e e i z h h i i m e
+p x x n g 0 a i 0 0 0 0 b b g g g g 1 1 1 1 x x i p l 
a d d n e u o r r x n
+a 2 2 d b 0   c e e e e   v b b b b 0 0 0 0 4 5 p   l 
p e e g d n s t t n v
+c x x i e 0   . v v   f e e e e k k k k e  
   v   a d t i i e i
+k   v n   . f f   . v v   . v v
   f   t e   o o t r
+e   f g   .   .   . f f   . f f
   a r . 3 t
+t v   v   v   v   v   v
   2 x v
+  e   e   e   e   e   e
   e
+  c   c   c   c   c   c
   c
+    = = = = = = = = = = = = = = = = = = = = = = = = = = = 
= = = = = = = = = = =
Speed capabilities
-   Link statusY Y   Y Y   Y Y Y Y   Y Y Y Y Y Y
 Y Y   Y Y Y Y
-   Link status event  Y Y Y Y Y Y   Y Y Y Y
 Y Y Y
-   Queue status event  
 Y
+   Link statusY Y   Y Y   Y Y Y Y   Y Y Y Y Y Y
 Y Y   Y Y Y Y Y
+   Link status event  Y Y Y Y Y Y   Y Y Y Y
 Y Y Y Y
+   Queue status event  
   Y
Rx interrupt   Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
-   Queue start/stop Y   Y Y Y Y Y Y Y Y Y Y Y Y Y Y
   Y   Y Y
-   MTU update   Y Y Y   Y   Y Y Y Y Y Y
-   Jumbo frame  Y Y Y Y Y Y Y Y Y   Y Y Y Y Y Y Y Y Y Y   
Y Y Y
-   Scattered Rx Y Y Y   Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
   Y   Y
+   Queue start/stop Y   Y Y Y Y Y Y Y Y Y Y Y Y Y Y
   Y Y   Y Y
+   MTU update   Y Y Y   Y   Y Y Y Y Y Y
 Y
+   Jumbo frame  Y Y Y Y Y Y Y Y Y   Y Y Y Y Y Y Y Y Y Y   
Y Y Y Y
+   Scattered Rx Y Y Y   Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y 

[dpdk-dev] [PATCH v5 25/25] maintainers: claim responsibility for the ThunderX nicvf PMD

2016-06-15 Thread Jerin Jacob
Signed-off-by: Jerin Jacob 
Signed-off-by: Maciej Czekaj 
---
 MAINTAINERS | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 3e8558f..625423f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -336,6 +336,12 @@ M: Sony Chacko 
 F: drivers/net/qede/
 F: doc/guides/nics/qede.rst

+Cavium ThunderX nicvf
+M: Jerin Jacob 
+M: Maciej Czekaj 
+F: drivers/net/thunderx/
+F: doc/guides/nics/thunderx.rst
+
 RedHat virtio
 M: Huawei Xie 
 M: Yuanhan Liu 
-- 
2.5.5



[dpdk-dev] [PATCH v2 00/30] ixgbe/base: update base driver

2016-06-15 Thread Xing, Beilei

> -Original Message-
> From: Yigit, Ferruh
> Sent: Tuesday, June 14, 2016 6:55 PM
> To: Xing, Beilei ; Lu, Wenzhuo  intel.com>
> Cc: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v2 00/30] ixgbe/base: update base driver
> 
> On 6/14/2016 11:36 AM, Ferruh Yigit wrote:
> > On 6/14/2016 7:59 AM, Beilei Xing wrote:
> >> Update base driver for ixgbe, mainly work on new features and bug fixes.
> >>
> >> v2 changes:
> >>  Fix typos and update commit log.
> >>  Separate [patch 18/29] into two patches.
> >>
> > ...
> >>
> >> Acked-by: Helin Zhang 
> >>
> > Series Reviewed-by Ferruh Yigit 
> >
> Hi Beilei,
> 
> running check-git-log.sh scrip identified a few more issues in patch subjects.
> 
> Can you please send a new version of patchset addressing following issues, 
> sorry
> for missing these at first review.
> 
> 1) Unify "X550EM_A" usage in patch subject and commit messages.
> ixgbe/base: fix firmware commands on x550em_a
> ixgbe/base: add KR support for X550EM_A devices
> 
> "X550em_a" seems preferred in old commits.
> 
> 2) Wrong headline lowercase:
> ixgbe/base: allow setting mac anti spoofing per vf
> ixgbe/base: add link mac setup for x550a SFP+
> ixgbe/base: add mac link setup for x550a SFP
> 
> mac and vf should be upercase
> 
> 3) Line too long:
> Added support for the VLVF to be bypassed when adding/removing a
> VFTA entry.
> 
> 4) Wrong tag:
> Fixes: 86b8fb293fdf ("ixgbe/base: add sw-firmware sync for resource
> sharing)
> 
> missing a " at the end.
> 
> 
> Regards,
> ferruh


Hi Ferruh,

Thanks for your careful review:)
After fixing some issues, there still exists warnings when running 
check-git-log.sh.
Can I ignore the two warnings?

1) Wrong headline format:
ixgbe/base: fix firmware commands on X550em_a
ixgbe/base: add KR support for X550em_a devices
Seems it's caused by '_' in name ' X550em_a '.

2) Line too long:
Fixes: 36f43e8679ae ("ixgbe/base: refactor manageability block 
communication")
Fixes: 86b8fb293fdf ("ixgbe/base: add sw-firmware sync for resource 
sharing on X550em_a")
Fixline shouldn't be separated into two lines, right?


[dpdk-dev] [PATCH v5 1/4] lib/librte_ether: support device reset

2016-06-15 Thread Wenzhuo Lu
Add an API to reset the device.
It's for VF device in this scenario, kernel PF + DPDK VF.
When the PF port down->up, APP should call this API to
reset VF port. Most likely, APP should call it in its
management thread and guarantee the thread safe. It means
APP should stop the rx/tx and the device, then reset the
device, then recover the device and rx/tx.

Signed-off-by: Wenzhuo Lu 
---
 lib/librte_ether/rte_ethdev.c  | 17 +
 lib/librte_ether/rte_ethdev.h  | 14 ++
 lib/librte_ether/rte_ether_version.map |  7 +++
 3 files changed, 38 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e148028..e43dca9 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3346,3 +3346,20 @@ rte_eth_dev_l2_tunnel_offload_set(uint8_t port_id,
-ENOTSUP);
return (*dev->dev_ops->l2_tunnel_offload_set)(dev, l2_tunnel, mask, en);
 }
+
+int
+rte_eth_dev_reset(uint8_t port_id)
+{
+   struct rte_eth_dev *dev;
+   int diag;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+
+   dev = _eth_devices[port_id];
+
+   RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_reset, -ENOTSUP);
+
+   diag = (*dev->dev_ops->dev_reset)(dev);
+
+   return diag;
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 2757510..74e895f 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1318,6 +1318,9 @@ typedef int (*eth_l2_tunnel_offload_set_t)
 uint8_t en);
 /**< @internal enable/disable the l2 tunnel offload functions */

+typedef int  (*eth_dev_reset_t)(struct rte_eth_dev *dev);
+/**< @internal Function used to reset a configured Ethernet device. */
+
 #ifdef RTE_NIC_BYPASS

 enum {
@@ -1508,6 +1511,8 @@ struct eth_dev_ops {
eth_l2_tunnel_eth_type_conf_t l2_tunnel_eth_type_conf;
/** Enable/disable l2 tunnel offload functions */
eth_l2_tunnel_offload_set_t l2_tunnel_offload_set;
+   /** Reset device. */
+   eth_dev_reset_t dev_reset;
 };

 /**
@@ -4253,6 +4258,15 @@ rte_eth_dev_l2_tunnel_offload_set(uint8_t port_id,
  uint32_t mask,
  uint8_t en);

+/**
+ * Reset an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ */
+int
+rte_eth_dev_reset(uint8_t port_id);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/librte_ether/rte_ether_version.map 
b/lib/librte_ether/rte_ether_version.map
index 214ecc7..c34207e 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -132,3 +132,10 @@ DPDK_16.04 {
rte_eth_tx_buffer_set_err_callback;

 } DPDK_2.2;
+
+DPDK_16.07 {
+   global:
+
+   rte_eth_dev_reset;
+
+} DPDK_16.04;
-- 
1.9.3



[dpdk-dev] [PATCH v5 0/4] support reset of VF link

2016-06-15 Thread Wenzhuo Lu
If the PF link is down and up, VF link will not work accordingly.
This patch set addes the support of VF link reset. So, when VF
receices the messges of physical link down/up. APP can reset the
VF link and let it recover.

PS: This patch set is splitted from a previous patch set,
*automatic link recovery on ixgbe/igb VF*, and it's base on the
patch set *support mailbox interruption on ixgbe/igb VF*.

Wenzhuo Lu (3):
  lib/librte_ether: support device reset
  ixgbe: implement device reset on VF
  igb: implement device reset on VF

Zhe Tao (1):
  i40e: implement device reset on VF

v1:
- Added the implementation for the VF reset functionality.
v2:
- Changed the i40e related operations during VF reset.
v3:
- Resent the patches because of the mail sent issue.
v4:
- Removed some VF reset emulation code.
v5:
- Removed all the code related with lock.

 doc/guides/rel_notes/release_16_07.rst | 13 ++
 drivers/net/e1000/igb_ethdev.c | 59 
 drivers/net/i40e/i40e_ethdev.h |  4 ++
 drivers/net/i40e/i40e_ethdev_vf.c  | 83 ++
 drivers/net/i40e/i40e_rxtx.c   | 10 
 drivers/net/i40e/i40e_rxtx.h   |  4 ++
 drivers/net/ixgbe/ixgbe_ethdev.c   | 64 +-
 drivers/net/ixgbe/ixgbe_ethdev.h   |  2 +-
 drivers/net/ixgbe/ixgbe_rxtx.c | 12 +++--
 lib/librte_ether/rte_ethdev.c  | 17 +++
 lib/librte_ether/rte_ethdev.h  | 14 ++
 lib/librte_ether/rte_ether_version.map |  7 +++
 12 files changed, 284 insertions(+), 5 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH v5 2/4] ixgbe: implement device reset on VF

2016-06-15 Thread Wenzhuo Lu
Implement the device reset function.

Signed-off-by: Wenzhuo Lu 
---
 doc/guides/rel_notes/release_16_07.rst |  9 +
 drivers/net/ixgbe/ixgbe_ethdev.c   | 64 +-
 drivers/net/ixgbe/ixgbe_ethdev.h   |  2 +-
 drivers/net/ixgbe/ixgbe_rxtx.c | 12 +--
 4 files changed, 82 insertions(+), 5 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index a761e3c..d36c4b1 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -53,6 +53,15 @@ New Features
   VF. To handle this link up/down event, add the mailbox interruption
   support to receive the message.

+* **Added device reset support for ixgbe VF.**
+
+  Added the device reset API. APP can call this API to reset the VF port
+  when it's not working.
+  Based on the mailbox interruption support, when VF reseives the control
+  message from PF, it means the PF link state changes, VF uses the reset
+  callback in the message handler to notice the APP. APP need call the device
+  reset API to reset the VF port.
+

 Resolved Issues
 ---
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 05f4f29..4e62cbb 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -381,6 +381,8 @@ static int ixgbe_dev_udp_tunnel_port_add(struct rte_eth_dev 
*dev,
 static int ixgbe_dev_udp_tunnel_port_del(struct rte_eth_dev *dev,
 struct rte_eth_udp_tunnel *udp_tunnel);

+static int ixgbevf_dev_reset(struct rte_eth_dev *dev);
+
 /*
  * Define VF Stats MACRO for Non "cleared on read" register
  */
@@ -586,6 +588,7 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
.reta_query   = ixgbe_dev_rss_reta_query,
.rss_hash_update  = ixgbe_dev_rss_hash_update,
.rss_hash_conf_get= ixgbe_dev_rss_hash_conf_get,
+   .dev_reset= ixgbevf_dev_reset,
 };

 /* store statistics names and its offset in stats structure */
@@ -4052,7 +4055,9 @@ ixgbevf_dev_start(struct rte_eth_dev *dev)
ETH_VLAN_EXTEND_MASK;
ixgbevf_vlan_offload_set(dev, mask);

-   ixgbevf_dev_rxtx_start(dev);
+   err = ixgbevf_dev_rxtx_start(dev);
+   if (err)
+   return err;

/* check and configure queue intr-vector mapping */
if (dev->data->dev_conf.intr_conf.rxq != 0) {
@@ -7185,6 +7190,63 @@ static void ixgbevf_mbx_process(struct rte_eth_dev *dev)
 }

 static int
+ixgbevf_dev_reset(struct rte_eth_dev *dev)
+{
+   struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   int diag = 0;
+   uint32_t vteiam;
+
+   /* Nothing needs to be done if the device is not started. */
+   if (!dev->data->dev_started)
+   return 0;
+
+   PMD_DRV_LOG(DEBUG, "Link up/down event detected.");
+
+   /* Performance VF reset. */
+   do {
+   dev->data->dev_started = 0;
+   ixgbevf_dev_stop(dev);
+   if (dev->data->dev_conf.intr_conf.lsc == 0)
+   diag = ixgbe_dev_link_update(dev, 0);
+   if (diag) {
+   PMD_INIT_LOG(INFO, "Ixgbe VF reset: "
+"Failed to update link.");
+   }
+   rte_delay_ms(1000);
+
+   diag = ixgbevf_dev_start(dev);
+   /*If fail to start the device, need to stop/start it again. */
+   if (diag) {
+   PMD_INIT_LOG(ERR, "Ixgbe VF reset: "
+"Failed to start device.");
+   continue;
+   }
+   dev->data->dev_started = 1;
+   ixgbevf_dev_stats_reset(dev);
+   if (dev->data->dev_conf.intr_conf.lsc == 0)
+   diag = ixgbe_dev_link_update(dev, 0);
+   if (diag) {
+   PMD_INIT_LOG(INFO, "Ixgbe VF reset: "
+"Failed to update link.");
+   diag = 0;
+   }
+
+   /**
+* When the PF link is down, there has chance
+* that VF cannot operate its registers. Will
+* check if the registers is written
+* successfully. If not, repeat stop/start until
+* the PF link is up, in other words, until the
+* registers can be written.
+*/
+   vteiam = IXGBE_READ_REG(hw, IXGBE_VTEIAM);
+   /* Reference ixgbevf_intr_enable when checking */
+   } while (diag || vteiam != IXGBE_VF_IRQ_ENABLE_MASK);
+
+   return 0;
+}
+
+static int
 ixgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev)
 {
uint32_t eicr;
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h
index 4ff6338..bc68b43 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.h

[dpdk-dev] [PATCH v5 3/4] igb: implement device reset on VF

2016-06-15 Thread Wenzhuo Lu
Implement the device reset function.

Signed-off-by: Wenzhuo Lu 
---
 doc/guides/rel_notes/release_16_07.rst |  2 +-
 drivers/net/e1000/igb_ethdev.c | 59 ++
 2 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index d36c4b1..a4c0cc3 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -53,7 +53,7 @@ New Features
   VF. To handle this link up/down event, add the mailbox interruption
   support to receive the message.

-* **Added device reset support for ixgbe VF.**
+* **Added device reset support for ixgbe/igb VF.**

   Added the device reset API. APP can call this API to reset the VF port
   when it's not working.
diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index b0e5e6a..f1ac4b5 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -268,6 +268,7 @@ static void eth_igb_configure_msix_intr(struct rte_eth_dev 
*dev);
 static void eth_igbvf_interrupt_handler(struct rte_intr_handle *handle,
void *param);
 static void igbvf_mbx_process(struct rte_eth_dev *dev);
+static int igbvf_dev_reset(struct rte_eth_dev *dev);

 /*
  * Define VF Stats MACRO for Non "cleared on read" register
@@ -409,6 +410,7 @@ static const struct eth_dev_ops igbvf_eth_dev_ops = {
.mac_addr_set = igbvf_default_mac_addr_set,
.get_reg_length   = igbvf_get_reg_length,
.get_reg  = igbvf_get_regs,
+   .dev_reset= igbvf_dev_reset,
 };

 /* store statistics names and its offset in stats structure */
@@ -2655,6 +2657,63 @@ void igbvf_mbx_process(struct rte_eth_dev *dev)
 }

 static int
+igbvf_dev_reset(struct rte_eth_dev *dev)
+{
+   struct e1000_hw *hw =
+   E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   int diag = 0;
+   uint32_t eiam;
+   /* Reference igbvf_intr_enable */
+   uint32_t eiam_mbx = 1 << E1000_VTIVAR_MISC_MAILBOX;
+
+   /* Nothing needs to be done if the device is not started. */
+   if (!dev->data->dev_started)
+   return 0;
+
+   PMD_DRV_LOG(DEBUG, "Link up/down event detected.");
+
+   /* Performance VF reset. */
+   do {
+   dev->data->dev_started = 0;
+   igbvf_dev_stop(dev);
+   if (dev->data->dev_conf.intr_conf.lsc == 0)
+   diag = eth_igb_link_update(dev, 0);
+   if (diag) {
+   PMD_INIT_LOG(INFO, "Igb VF reset: "
+"Failed to update link.");
+   }
+   rte_delay_ms(1000);
+
+   diag = igbvf_dev_start(dev);
+   if (diag) {
+   PMD_INIT_LOG(ERR, "Igb VF reset: "
+"Failed to start device.");
+   return diag;
+   }
+   dev->data->dev_started = 1;
+   eth_igbvf_stats_reset(dev);
+   if (dev->data->dev_conf.intr_conf.lsc == 0)
+   diag = eth_igb_link_update(dev, 0);
+   if (diag) {
+   PMD_INIT_LOG(INFO, "Igb VF reset: "
+"Failed to update link.");
+   }
+
+   /**
+* When the PF link is down, there has chance
+* that VF cannot operate its registers. Will
+* check if the registers is written
+* successfully. If not, repeat stop/start until
+* the PF link is up, in other words, until the
+* registers can be written.
+*/
+   eiam = E1000_READ_REG(hw, E1000_EIAM);
+   } while (!(eiam & eiam_mbx));
+
+   return 0;
+}
+
+static int
 eth_igbvf_interrupt_action(struct rte_eth_dev *dev)
 {
struct e1000_interrupt *intr =
-- 
1.9.3



[dpdk-dev] [PATCH v5 4/4] i40e: implement device reset on VF

2016-06-15 Thread Wenzhuo Lu
Implement the device reset function.
This reset function will detach device then
attach device, reconfigure dev, re-setup the Rx/Tx queues.

Signed-off-by: Zhe Tao 
---
 doc/guides/rel_notes/release_16_07.rst |  4 ++
 drivers/net/i40e/i40e_ethdev.h |  4 ++
 drivers/net/i40e/i40e_ethdev_vf.c  | 83 ++
 drivers/net/i40e/i40e_rxtx.c   | 10 
 drivers/net/i40e/i40e_rxtx.h   |  4 ++
 5 files changed, 105 insertions(+)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index a4c0cc3..6661b07 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -62,6 +62,10 @@ New Features
   callback in the message handler to notice the APP. APP need call the device
   reset API to reset the VF port.

+* **Added VF reset support for i40e VF driver.**
+
+  Added a new implementaion to allow i40e VF driver to
+  reset the functionality and state of itself.

 Resolved Issues
 ---
diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index cfd2399..4e0df3b 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -540,6 +540,8 @@ struct i40e_adapter {
struct rte_timecounter systime_tc;
struct rte_timecounter rx_tstamp_tc;
struct rte_timecounter tx_tstamp_tc;
+   /* For VF reset */
+   uint8_t reset_number;
 };

 int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
@@ -593,6 +595,8 @@ void i40e_rxq_info_get(struct rte_eth_dev *dev, uint16_t 
queue_id,
 void i40e_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
struct rte_eth_txq_info *qinfo);

+void i40evf_emulate_vf_reset(uint8_t port_id);
+
 /* I40E_DEV_PRIVATE_TO */
 #define I40E_DEV_PRIVATE_TO_PF(adapter) \
(&((struct i40e_adapter *)adapter)->pf)
diff --git a/drivers/net/i40e/i40e_ethdev_vf.c 
b/drivers/net/i40e/i40e_ethdev_vf.c
index 90682ac..2f65a29 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -157,6 +157,12 @@ i40evf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, 
uint16_t queue_id);
 static void i40evf_handle_pf_event(__rte_unused struct rte_eth_dev *dev,
   uint8_t *msg,
   uint16_t msglen);
+static int i40evf_dev_uninit(struct rte_eth_dev *eth_dev);
+static int i40evf_dev_init(struct rte_eth_dev *eth_dev);
+static void i40evf_dev_close(struct rte_eth_dev *dev);
+static int i40evf_dev_start(struct rte_eth_dev *dev);
+static int i40evf_dev_configure(struct rte_eth_dev *dev);
+static int i40evf_handle_vf_reset(struct rte_eth_dev *dev);

 /* Default hash key buffer for RSS */
 static uint32_t rss_key_default[I40E_VFQF_HKEY_MAX_INDEX + 1];
@@ -223,6 +229,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = {
.reta_query   = i40evf_dev_rss_reta_query,
.rss_hash_update  = i40evf_dev_rss_hash_update,
.rss_hash_conf_get= i40evf_dev_rss_hash_conf_get,
+   .dev_reset= i40evf_handle_vf_reset
 };

 /*
@@ -1309,6 +1316,82 @@ i40evf_uninit_vf(struct rte_eth_dev *dev)
 }

 static void
+i40e_vf_queue_reset(struct rte_eth_dev *dev)
+{
+   uint16_t i;
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   struct i40e_rx_queue *rxq = dev->data->rx_queues[i];
+
+   if (rxq->q_set) {
+   i40e_dev_rx_queue_setup(dev,
+   rxq->queue_id,
+   rxq->nb_rx_desc,
+   rxq->socket_id,
+   >rxconf,
+   rxq->mp);
+   }
+   }
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   struct i40e_tx_queue *txq = dev->data->tx_queues[i];
+
+   if (txq->q_set) {
+   i40e_dev_tx_queue_setup(dev,
+   txq->queue_id,
+   txq->nb_tx_desc,
+   txq->socket_id,
+   >txconf);
+   }
+   }
+}
+
+static void
+i40e_vf_reset_dev(struct rte_eth_dev *dev)
+{
+   struct i40e_adapter *adapter =
+   I40E_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private);
+
+   i40evf_dev_close(dev);
+   PMD_DRV_LOG(DEBUG, "i40evf dev close complete");
+   i40evf_dev_uninit(dev);
+   PMD_DRV_LOG(DEBUG, "i40evf dev detached");
+   memset(dev->data->dev_private, 0,
+  (uint64_t)>reset_number - (uint64_t)adapter);
+
+   i40evf_dev_configure(dev);
+   i40evf_dev_init(dev);
+   PMD_DRV_LOG(DEBUG, "i40evf dev attached");
+   i40e_vf_queue_reset(dev);
+   PMD_DRV_LOG(DEBUG, "i40evf queue reset");
+   i40evf_dev_start(dev);
+ 

[dpdk-dev] [PATCH] eal: Fix resource leak of pci_uio_map_secondary()

2016-06-15 Thread Tetsuya Mukawa
If pci_map_resource() succeeds but mapped address is different from an
address primary process mapped, this should be error.
Then the address secondary process mapped should be freed.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_pci_uio.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/librte_eal/common/eal_common_pci_uio.c 
b/lib/librte_eal/common/eal_common_pci_uio.c
index f062e81..e718643 100644
--- a/lib/librte_eal/common/eal_common_pci_uio.c
+++ b/lib/librte_eal/common/eal_common_pci_uio.c
@@ -85,6 +85,9 @@ pci_uio_map_secondary(struct rte_pci_device *dev)
"Cannot mmap device resource file %s to 
address: %p\n",
uio_res->maps[i].path,
uio_res->maps[i].addr);
+   if (mapaddr != MAP_FAILED)
+   pci_unmap_resource(mapaddr,
+   (size_t)uio_res->maps[i].size);
return -1;
}
}
-- 
2.7.4



[dpdk-dev] [PATCH] eal: Fix wrong error checking of rte_eal_parse_devargs_str()

2016-06-15 Thread Tetsuya Mukawa
Currently, a return value of strdup() isn't checked correctly.
The patch fixes it.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_devargs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_devargs.c 
b/lib/librte_eal/common/eal_common_devargs.c
index 2bfe54a..e403717 100644
--- a/lib/librte_eal/common/eal_common_devargs.c
+++ b/lib/librte_eal/common/eal_common_devargs.c
@@ -58,7 +58,7 @@ rte_eal_parse_devargs_str(const char *devargs_str,
return -1;

*drvname = strdup(devargs_str);
-   if (drvname == NULL)
+   if (*drvname == NULL)
return -1;

/* set the first ',' to '\0' to split name and arguments */
-- 
2.7.4



[dpdk-dev] [PATCH] eal: Fix wrong resource release of pci_uio_unmap()

2016-06-15 Thread Tetsuya Mukawa
The 'path' member of mapped_pci_resource structure is allocated by
primary process, but currenctly it will be freed by both primary
and secondary process.
The patch fixes to be freed by only primary process.

Signed-off-by: Tetsuya Mukawa 
---
 lib/librte_eal/common/eal_common_pci_uio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/common/eal_common_pci_uio.c 
b/lib/librte_eal/common/eal_common_pci_uio.c
index e718643..b2c68f3 100644
--- a/lib/librte_eal/common/eal_common_pci_uio.c
+++ b/lib/librte_eal/common/eal_common_pci_uio.c
@@ -162,7 +162,9 @@ pci_uio_unmap(struct mapped_pci_resource *uio_res)
for (i = 0; i != uio_res->nb_maps; i++) {
pci_unmap_resource(uio_res->maps[i].addr,
(size_t)uio_res->maps[i].size);
-   rte_free(uio_res->maps[i].path);
+
+   if (rte_eal_process_type() == RTE_PROC_PRIMARY)
+   rte_free(uio_res->maps[i].path);
}
 }

-- 
2.7.4



[dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx callback lists

2016-06-15 Thread Pattan, Reshma


> -Original Message-
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Tuesday, June 14, 2016 9:00 PM
> To: Pattan, Reshma 
> Cc: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx
> callback lists
> 
> 2016-06-14 10:38, Reshma Pattan:
> > Added spinlocks around add/remove logic of Rx and Tx callbacks to
> > avoid corruption of callback lists in multithreaded context.
> >
> > Signed-off-by: Reshma Pattan 
> 
> Why cb->next is not locked in burst functions?
It is safe to do "read access" here and doesn't require any locking as rx/tx 
burst is initiated  by only local user(control plane) thread.

> Just protecting add/remove but not its usage seems useless.
Here locks were required  around add/remove to protect "write access"  because 
write to callback list is now done from 2 threads 
i.e. one from local user thread(control plane) and another from pdump control 
thread(initiated by remote pdump request). 

Thanks,
Reshma



[dpdk-dev] [PATCH v9 8/8] doc: update doc for packet capture framework

2016-06-15 Thread Pattan, Reshma


> -Original Message-
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Tuesday, June 14, 2016 9:41 PM
> To: Pattan, Reshma 
> Cc: dev at dpdk.org; Mcnamara, John 
> Subject: Re: [dpdk-dev] [PATCH v9 8/8] doc: update doc for packet capture
> framework
> 
> When commenting previous patches, I missed these docs.
> Please move them in the appropriate patches.
> 
> > +Use Case: Packet Capturing
> > +--
> > +
> > +The DPDK ``app/pdump`` tool is developed based on this library to capture
> packets in DPDK.
> > +Users can use this as an example to develop their own packet capturing
> application.
> 
> Is it an example or a debugging tool?

It is a debugging tool.

> If it is an example, it should be in the examples/ directory.
> 
> >  ABI Changes
> >  ---
> > @@ -146,6 +156,9 @@ ABI Changes
> >  * The ``rte_port_source_params`` structure has new fields to support PCAP
> file.
> >It was already in release 16.04 with ``RTE_NEXT_ABI`` flag.
> >
> > +* The ``rte_eth_dev_info`` structure has new fields ``nb_rx_queues`` and
> ``nb_tx_queues``
> > +  to support number of queues configured by software.
> 
> There was no deprecation notice in 16.04 for this ABI change.

Deprecation notice and relevant planed changes were sent as RFC during the 
start of 16.07 , please find the below is the link for the same.
http://dpdk.org/dev/patchwork/patch/12033/
http://dpdk.org/dev/patchwork/patch/12034/

Thanks,
Reshma


[dpdk-dev] [PATCH v1 07/28] eal/soc: add rte_eal_soc_register/unregister logic

2016-06-15 Thread Shreyansh Jain
Hi Jan,

One more comment which I missed in previous reply:

> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Shreyansh Jain
> Sent: Monday, June 13, 2016 7:50 PM
> To: Jan Viktorin 
> Cc: David Marchand ; Thomas Monjalon
> ; Bruce Richardson  intel.com>;
> Declan Doherty ; jianbo.liu at linaro.org;
> jerin.jacob at caviumnetworks.com; Keith Wiles ; 
> Stephen
> Hemminger ; dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v1 07/28] eal/soc: add
> rte_eal_soc_register/unregister logic
> 
> Another trivial comment inlined:
> 
> > -Original Message-
> > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jan Viktorin
> > Sent: Friday, May 06, 2016 7:18 PM
> > To: dev at dpdk.org
> > Cc: Jan Viktorin ; David Marchand
> > ; Thomas Monjalon  > 6wind.com>;
> > Bruce Richardson ; Declan Doherty
> > ; jianbo.liu at linaro.org;
> > jerin.jacob at caviumnetworks.com; Keith Wiles ;
> Stephen
> > Hemminger 
> > Subject: [dpdk-dev] [PATCH v1 07/28] eal/soc: add
> > rte_eal_soc_register/unregister logic
> >
> > Signed-off-by: Jan Viktorin 
> > ---
> >  app/test/test_soc.c | 106
> > 
> >  lib/librte_eal/bsdapp/eal/Makefile  |   1 +
> >  lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   3 +
> >  lib/librte_eal/common/eal_common_soc.c  |  55 
> >  lib/librte_eal/common/include/rte_soc.h |  23 +
> >  lib/librte_eal/linuxapp/eal/Makefile|   1 +
> >  lib/librte_eal/linuxapp/eal/rte_eal_version.map |   4 +
> >  7 files changed, 193 insertions(+)
> >  create mode 100644 lib/librte_eal/common/eal_common_soc.c
> >
> > diff --git a/app/test/test_soc.c b/app/test/test_soc.c
> > index a49fc9b..f6288dc 100644
> > --- a/app/test/test_soc.c
> > +++ b/app/test/test_soc.c
> > @@ -74,6 +74,103 @@ static int test_compare_addr(void)
> > free(a2.name);
> > free(a1.name);
> > free(a0.name);
> > +
> > +   return 0;
> > +}
> > +
> > +/**
> > + * Empty PMD driver based on the SoC infra.
> > + *
> > + * The rte_soc_device is usually wrapped in some higher-level struct
> > + * (eth_driver). We simulate such a wrapper with an anonymous struct here.
> > + */
> > +struct test_wrapper {
> > +   struct rte_soc_driver soc_drv;
> > +};
> > +
> > +struct test_wrapper empty_pmd0 = {
> > +   .soc_drv = {
> > +   .name = "empty_pmd0",
> > +   },
> > +};
> > +
> > +struct test_wrapper empty_pmd1 = {
> > +   .soc_drv = {
> > +   .name = "empty_pmd1",
> > +   },
> > +};
> > +
> > +static int
> > +count_registered_socdrvs(void)
> > +{
> > +   int i;
> > +   struct rte_soc_driver *drv;
> > +
> > +   i = 0;
> > +   TAILQ_FOREACH(drv, _driver_list, next)
> > +   i += 1;
> > +
> > +   return i;
> > +}
> > +
> > +static int
> > +test_register_unregister(void)
> > +{
> > +   struct rte_soc_driver *drv;
> > +   int count;
> > +
> > +   rte_eal_soc_register(_pmd0.soc_drv);
> > +
> > +   TEST_ASSERT(!TAILQ_EMPTY(_driver_list),
> > +   "No PMD is present but the empty_pmd0 should be there");
> > +   drv = TAILQ_FIRST(_driver_list);
> > +   TEST_ASSERT(!strcmp(drv->name, "empty_pmd0"),
> > +   "The registered PMD is not empty_pmd but '%s'", drv->name);
> 
> Trivial: TEST_ASSERT Message should be: "... is not empty_pmd0 but..."
> 
> > +
> > +   rte_eal_soc_register(_pmd1.soc_drv);
> > +
> > +   count = count_registered_socdrvs();
> > +   TEST_ASSERT_EQUAL(count, 2, "Expected 2 PMDs but detected %d", count);
> > +
> > +   rte_eal_soc_unregister(_pmd0.soc_drv);
> > +   count = count_registered_socdrvs();
> > +   TEST_ASSERT_EQUAL(count, 1, "Expected 1 PMDs but detected %d", count);
> > +
> > +   rte_eal_soc_unregister(_pmd1.soc_drv);
> > +
> > +   printf("%s has been successful\n", __func__);
> > +   return 0;
> > +}
> > +
> > +/* save real devices and drivers until the tests finishes */
> > +struct soc_driver_list real_soc_driver_list =
> > +   TAILQ_HEAD_INITIALIZER(real_soc_driver_list);
> > +
> > +static int test_soc_setup(void)
> > +{
> > +   struct rte_soc_driver *drv;
> > +
> > +   /* no real drivers for the test */
> > +   while (!TAILQ_EMPTY(_driver_list)) {
> > +   drv = TAILQ_FIRST(_driver_list);
> > +   rte_eal_soc_unregister(drv);
> > +   TAILQ_INSERT_TAIL(_soc_driver_list, drv, next);
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> > +static int test_soc_cleanup(void)
> > +{
> > +   struct rte_soc_driver *drv;
> > +
> > +   /* bring back real drivers after the test */
> > +   while (!TAILQ_EMPTY(_soc_driver_list)) {
> > +   drv = TAILQ_FIRST(_soc_driver_list);
> > +   TAILQ_REMOVE(_soc_driver_list, drv, next);
> > +   rte_eal_soc_register(drv);
> > +   }
> > +
> > return 0;
> >  }
> >
> > @@ -83,6 +180,15 @@ test_soc(void)
> > if (test_compare_addr())
> > return -1;
> >
> > +   if (test_soc_setup())
> > +   return -1;
> > +
> > +   if (test_register_unregister())
> > +   

[dpdk-dev] [PATCH] doc: virtio pmd versions

2016-06-15 Thread Wang, Zhihong


> -Original Message-
> From: Mcnamara, John
> Sent: Thursday, June 9, 2016 8:56 PM
> To: Richardson, Bruce ; Wang, Zhihong
> ; dev at dpdk.org
> Cc: Wang, Zhihong 
> Subject: RE: [dpdk-dev] [PATCH] doc: virtio pmd versions
> 
> > -Original Message-
> > From: Richardson, Bruce
> > Sent: Thursday, June 9, 2016 1:53 PM
> > To: Mcnamara, John ; Wang, Zhihong
> > ; dev at dpdk.org
> > Cc: Wang, Zhihong 
> > Subject: RE: [dpdk-dev] [PATCH] doc: virtio pmd versions
> >
> > > -Original Message-
> > > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Mcnamara, John
> > 
> > >
> > > > -Original Message-
> > > > From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Zhihong Wang
> > 
> > > > +
> > > > +Virtio PMD Versions
> > > > +---
> > > > +
> > > > +Virtio driver has 3 versions of rx functions and 2 versions of tx
> > > > functions.
> > >
> > > In some places RX/TX is used and in some rx/tx. I would suggest the
> > > uppercase versions throughout.
> > >
> >
> > In the commit logs, the only valid contractions allowed by the check-git-
> > log.sh script are Rx and Tx
> >
> > bad=$(echo "$headlines" | grep -E --color=always \
> > -e '\<(rx|tx|RX|TX)\>' \
> >  
> >
> > I would therefore suggest we follow the same rules for the docs for
> > consistency.
> 
> Hi,
> 
> I don't mind what it is once we have consistency, so Rx/Tx is fine. Zhihong,
> please note.

Thank you John and Bruce!
V2 has been sent, please take a look.

> 
> John
> 
> 



[dpdk-dev] [PATCH v2 5/5] testpmd: show topology at forwarding start

2016-06-15 Thread Wang, Zhihong


> -Original Message-
> From: De Lara Guarch, Pablo
> Sent: Tuesday, June 14, 2016 11:13 PM
> To: Wang, Zhihong ; dev at dpdk.org
> Cc: Ananyev, Konstantin ; Richardson, Bruce
> ; thomas.monjalon at 6wind.com
> Subject: RE: [PATCH v2 5/5] testpmd: show topology at forwarding start
> 
> 
> Hi Zhihong,
> 
> > -Original Message-
> > From: Wang, Zhihong
> > Sent: Wednesday, June 01, 2016 4:28 AM
> > To: dev at dpdk.org
> > Cc: Ananyev, Konstantin; Richardson, Bruce; De Lara Guarch, Pablo;
> > thomas.monjalon at 6wind.com; Wang, Zhihong
> > Subject: [PATCH v2 5/5] testpmd: show topology at forwarding start
> >
> > This patch show topology at forwarding start.
> >
> > "show config fwd" also does this, but showing it directly can reduce the
> > possibility of misconfiguration.
> >
> >
> > Signed-off-by: Zhihong Wang 
> [...]
> 
> > diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
> > index 9b1d99c..b946034 100644
> > --- a/app/test-pmd/testpmd.c
> > +++ b/app/test-pmd/testpmd.c
> > @@ -1009,7 +1009,7 @@ start_packet_forwarding(int with_tx_first)
> > if(!no_flush_rx)
> > flush_fwd_rx_queues();
> >
> > -   fwd_config_setup();
> > +   fwd_config_setup_display();
> 
> Bernard has made a patch that separates the display and setup of the
> configuration,
> (http://dpdk.org/dev/patchwork/patch/13650/)
> so fwd_config_display() does not call fwd_config_setup() anymore.
> 
> Could you modify this patch, so you call fwd_config_setup() and
> fwd_config_display()?

Thanks for the info! I've updated this patch with a v3.
Could you please help review?


> 
> Sorry for the confusion,
> Pablo
> 
> > rxtx_config_display();
> >
> > for (i = 0; i < cur_fwd_config.nb_fwd_ports; i++) {



[dpdk-dev] [PATCH v12 0/3] mempool: add external mempool manager

2016-06-15 Thread David Hunt
Here's the latest version of the External Mempool Manager patchset.
It's re-based on top of the latest head as of 14/6/2016, including
Olivier's 35-part patch series on mempool re-org [1]

[1] http://dpdk.org/ml/archives/dev/2016-May/039229.html

v12 changes:

 * Fixed a comment (function pram h -> ops)
 * Fixed a typo in mempool docs (callbacki)

v11 changes:

 * Fixed comments (added '.' where needed for consistency)
 * removed ABI breakage notice for mempool manager in deprecation.rst
 * Added description of the external mempool manager functionality to
   doc/guides/prog_guide/mempool_lib.rst (John Mc reviewed)
 * renamed rte_mempool_default.c to rte_mempool_ring.c

v10 changes:

 * changed the _put/_get op names to _enqueue/_dequeue to be consistent
   with the function names
 * some rte_errno cleanup
 * comment tweaks about when to set pool_data
 * removed an un-needed check for ops->alloc == NULL

v9 changes:

 * added a check for NULL alloc in rte_mempool_ops_register
 * rte_mempool_alloc_t now returns int instead of void*
 * fixed some comment typo's
 * removed some unneeded typecasts
 * changed a return NULL to return -EEXIST in rte_mempool_ops_register
 * fixed rte_mempool_version.map file so builds ok as shared libs
 * moved flags check from rte_mempool_create_empty to rte_mempool_create

v8 changes:

 * merged first three patches in the series into one.
 * changed parameters to ops callback to all be rte_mempool pointer
   rather than than pointer to opaque data or uint64.
 * comment fixes.
 * fixed parameter to _free function (was inconsistent).
 * changed MEMPOOL_F_RING_CREATED to MEMPOOL_F_POOL_CREATED

v7 changes:

 * Changed rte_mempool_handler_table to rte_mempool_ops_table
 * Changed hander_idx to ops_index in rte_mempool struct
 * Reworked comments in rte_mempool.h around ops functions
 * Changed rte_mempool_hander.c to rte_mempool_ops.c
 * Changed all functions containing _handler_ to _ops_
 * Now there is no mention of 'handler' left
 * Other small changes out of review of mailing list

v6 changes:

 * Moved the flags handling from rte_mempool_create_empty to
   rte_mempool_create, as it's only there for backward compatibility
 * Various comment additions and cleanup
 * Renamed rte_mempool_handler to rte_mempool_ops
 * Added a union for *pool and u64 pool_id in struct rte_mempool
 * split the original patch into a few parts for easier review.
 * rename functions with _ext_ to _ops_.
 * addressed review comments
 * renamed put and get functions to enqueue and dequeue
 * changed occurences of rte_mempool_ops to const, as they
   contain function pointers (security)
 * split out the default external mempool handler into a separate
   patch for easier review

v5 changes:
 * rebasing, as it is dependent on another patch series [1]

v4 changes (Olivier Matz):
 * remove the rte_mempool_create_ext() function. To change the handler, the
   user has to do the following:
   - mp = rte_mempool_create_empty()
   - rte_mempool_set_handler(mp, "my_handler")
   - rte_mempool_populate_default(mp)
   This avoids to add another function with more than 10 arguments, duplicating
   the doxygen comments
 * change the api of rte_mempool_alloc_t: only the mempool pointer is required
   as all information is available in it
 * change the api of rte_mempool_free_t: remove return value
 * move inline wrapper functions from the .c to the .h (else they won't be
   inlined). This implies to have one header file (rte_mempool.h), or it
   would have generate cross dependencies issues.
 * remove now unused MEMPOOL_F_INT_HANDLER (note: it was misused anyway due
   to the use of && instead of &)
 * fix build in debug mode (__MEMPOOL_STAT_ADD(mp, put_pool, n) remaining)
 * fix build with shared libraries (global handler has to be declared in
   the .map file)
 * rationalize #include order
 * remove unused function rte_mempool_get_handler_name()
 * rename some structures, fields, functions
 * remove the static in front of rte_tailq_elem rte_mempool_tailq (comment
   from Yuanhan)
 * test the ext mempool handler in the same file than standard mempool tests,
   avoiding to duplicate the code
 * rework the custom handler in mempool_test
 * rework a bit the patch selecting default mbuf pool handler
 * fix some doxygen comments

v3 changes:
 * simplified the file layout, renamed to rte_mempool_handler.[hc]
 * moved the default handlers into rte_mempool_default.c
 * moved the example handler out into app/test/test_ext_mempool.c
 * removed is_mc/is_mp change, slight perf degredation on sp cached operation
 * removed stack hanler, may re-introduce at a later date
 * Changes out of code reviews

v2 changes:
 * There was a lot of duplicate code between rte_mempool_xmem_create and
   rte_mempool_create_ext. This has now been refactored and is now
   hopefully cleaner.
 * The RTE_NEXT_ABI define is now used to allow building of the library
   in a format that is compatible with binaries built against previous
   versions of DPDK.
 

[dpdk-dev] [PATCH v12 2/3] app/test: test external mempool manager

2016-06-15 Thread David Hunt
Use a minimal custom mempool external ops and check that it also
passes basic mempool autotests.

Signed-off-by: Olivier Matz 
Signed-off-by: David Hunt 
Acked-by: Shreyansh Jain 
Acked-by: Olivier Matz 
---
 app/test/test_mempool.c | 122 +++-
 1 file changed, 120 insertions(+), 2 deletions(-)

diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
index b586249..bcf379b 100644
--- a/app/test/test_mempool.c
+++ b/app/test/test_mempool.c
@@ -83,6 +83,99 @@
 static rte_atomic32_t synchro;

 /*
+ * Simple example of custom mempool structure. Holds pointers to all the
+ * elements which are simply malloc'd in this example.
+ */
+struct custom_mempool {
+   rte_spinlock_t lock;
+   unsigned count;
+   unsigned size;
+   void *elts[];
+};
+
+/*
+ * Loop through all the element pointers and allocate a chunk of memory, then
+ * insert that memory into the ring.
+ */
+static int
+custom_mempool_alloc(struct rte_mempool *mp)
+{
+   struct custom_mempool *cm;
+
+   cm = rte_zmalloc("custom_mempool",
+   sizeof(struct custom_mempool) + mp->size * sizeof(void *), 0);
+   if (cm == NULL)
+   return -ENOMEM;
+
+   rte_spinlock_init(>lock);
+   cm->count = 0;
+   cm->size = mp->size;
+   mp->pool_data = cm;
+   return 0;
+}
+
+static void
+custom_mempool_free(struct rte_mempool *mp)
+{
+   rte_free((void *)(mp->pool_data));
+}
+
+static int
+custom_mempool_enqueue(struct rte_mempool *mp, void * const *obj_table,
+   unsigned n)
+{
+   struct custom_mempool *cm = (struct custom_mempool *)(mp->pool_data);
+   int ret = 0;
+
+   rte_spinlock_lock(>lock);
+   if (cm->count + n > cm->size) {
+   ret = -ENOBUFS;
+   } else {
+   memcpy(>elts[cm->count], obj_table, sizeof(void *) * n);
+   cm->count += n;
+   }
+   rte_spinlock_unlock(>lock);
+   return ret;
+}
+
+
+static int
+custom_mempool_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n)
+{
+   struct custom_mempool *cm = (struct custom_mempool *)(mp->pool_data);
+   int ret = 0;
+
+   rte_spinlock_lock(>lock);
+   if (n > cm->count) {
+   ret = -ENOENT;
+   } else {
+   cm->count -= n;
+   memcpy(obj_table, >elts[cm->count], sizeof(void *) * n);
+   }
+   rte_spinlock_unlock(>lock);
+   return ret;
+}
+
+static unsigned
+custom_mempool_get_count(const struct rte_mempool *mp)
+{
+   struct custom_mempool *cm = (struct custom_mempool *)(mp->pool_data);
+
+   return cm->count;
+}
+
+static struct rte_mempool_ops mempool_ops_custom = {
+   .name = "custom_handler",
+   .alloc = custom_mempool_alloc,
+   .free = custom_mempool_free,
+   .enqueue = custom_mempool_enqueue,
+   .dequeue = custom_mempool_dequeue,
+   .get_count = custom_mempool_get_count,
+};
+
+MEMPOOL_REGISTER_OPS(mempool_ops_custom);
+
+/*
  * save the object number in the first 4 bytes of object data. All
  * other bytes are set to 0.
  */
@@ -292,12 +385,14 @@ static int test_mempool_single_consumer(void)
  * test function for mempool test based on singple consumer and single 
producer,
  * can run on one lcore only
  */
-static int test_mempool_launch_single_consumer(__attribute__((unused)) void 
*arg)
+static int
+test_mempool_launch_single_consumer(__attribute__((unused)) void *arg)
 {
return test_mempool_single_consumer();
 }

-static void my_mp_init(struct rte_mempool * mp, __attribute__((unused)) void * 
arg)
+static void
+my_mp_init(struct rte_mempool *mp, __attribute__((unused)) void *arg)
 {
printf("mempool name is %s\n", mp->name);
/* nothing to be implemented here*/
@@ -477,6 +572,7 @@ test_mempool(void)
 {
struct rte_mempool *mp_cache = NULL;
struct rte_mempool *mp_nocache = NULL;
+   struct rte_mempool *mp_ext = NULL;

rte_atomic32_init();

@@ -505,6 +601,27 @@ test_mempool(void)
goto err;
}

+   /* create a mempool with an external handler */
+   mp_ext = rte_mempool_create_empty("test_ext",
+   MEMPOOL_SIZE,
+   MEMPOOL_ELT_SIZE,
+   RTE_MEMPOOL_CACHE_MAX_SIZE, 0,
+   SOCKET_ID_ANY, 0);
+
+   if (mp_ext == NULL) {
+   printf("cannot allocate mp_ext mempool\n");
+   goto err;
+   }
+   if (rte_mempool_set_ops_byname(mp_ext, "custom_handler") < 0) {
+   printf("cannot set custom handler\n");
+   goto err;
+   }
+   if (rte_mempool_populate_default(mp_ext) < 0) {
+   printf("cannot populate mp_ext mempool\n");
+   goto err;
+   }
+   rte_mempool_obj_iter(mp_ext, my_obj_init, NULL);
+
/* retrieve the mempool from its name */
if (rte_mempool_lookup("test_nocache") != mp_nocache) {
printf("Cannot lookup mempool from its 

[dpdk-dev] [PATCH v12 3/3] mbuf: make default mempool ops configurable at build

2016-06-15 Thread David Hunt
By default, the mempool ops used for mbuf allocations is a multi
producer and multi consumer ring. We could imagine a target (maybe some
network processors?) that provides an hardware-assisted pool
mechanism. In this case, the default configuration for this architecture
would contain a different value for RTE_MBUF_DEFAULT_MEMPOOL_OPS.

Signed-off-by: Olivier Matz 
Signed-off-by: David Hunt 
Acked-by: Shreyansh Jain 
Acked-by: Olivier Matz 
---
 config/common_base |  1 +
 lib/librte_mbuf/rte_mbuf.c | 26 ++
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/config/common_base b/config/common_base
index b9ba405..13ad4dd 100644
--- a/config/common_base
+++ b/config/common_base
@@ -394,6 +394,7 @@ CONFIG_RTE_LIBRTE_MEMPOOL_DEBUG=n
 #
 CONFIG_RTE_LIBRTE_MBUF=y
 CONFIG_RTE_LIBRTE_MBUF_DEBUG=n
+CONFIG_RTE_MBUF_DEFAULT_MEMPOOL_OPS="ring_mp_mc"
 CONFIG_RTE_MBUF_REFCNT_ATOMIC=y
 CONFIG_RTE_PKTMBUF_HEADROOM=128

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index eec1456..491230c 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -153,6 +153,7 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
unsigned cache_size, uint16_t priv_size, uint16_t data_room_size,
int socket_id)
 {
+   struct rte_mempool *mp;
struct rte_pktmbuf_pool_private mbp_priv;
unsigned elt_size;

@@ -167,10 +168,27 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,
mbp_priv.mbuf_data_room_size = data_room_size;
mbp_priv.mbuf_priv_size = priv_size;

-   return rte_mempool_create(name, n, elt_size,
-   cache_size, sizeof(struct rte_pktmbuf_pool_private),
-   rte_pktmbuf_pool_init, _priv, rte_pktmbuf_init, NULL,
-   socket_id, 0);
+   mp = rte_mempool_create_empty(name, n, elt_size, cache_size,
+sizeof(struct rte_pktmbuf_pool_private), socket_id, 0);
+   if (mp == NULL)
+   return NULL;
+
+   rte_errno = rte_mempool_set_ops_byname(mp,
+   RTE_MBUF_DEFAULT_MEMPOOL_OPS);
+   if (rte_errno != 0) {
+   RTE_LOG(ERR, MBUF, "error setting mempool handler\n");
+   return NULL;
+   }
+   rte_pktmbuf_pool_init(mp, _priv);
+
+   if (rte_mempool_populate_default(mp) < 0) {
+   rte_mempool_free(mp);
+   return NULL;
+   }
+
+   rte_mempool_obj_iter(mp, rte_pktmbuf_init, NULL);
+
+   return mp;
 }

 /* do some sanity checks on a mbuf: panic if it fails */
-- 
2.5.5



[dpdk-dev] [PATCH v12 1/3] mempool: support external mempool operations

2016-06-15 Thread David Hunt
Until now, the objects stored in a mempool were internally stored in a
ring. This patch introduces the possibility to register external handlers
replacing the ring.

The default behavior remains unchanged, but calling the new function
rte_mempool_set_ops_byname() right after rte_mempool_create_empty() allows
the user to change the handler that will be used when populating
the mempool.

This patch also adds a set of default ops (function callbacks) based
on rte_ring.

Signed-off-by: Olivier Matz 
Signed-off-by: David Hunt 
Acked-by: Shreyansh Jain 
Acked-by: Olivier Matz 
---
 app/test/test_mempool_perf.c   |   1 -
 doc/guides/prog_guide/mempool_lib.rst  |  31 +++-
 doc/guides/rel_notes/deprecation.rst   |   9 --
 lib/librte_mempool/Makefile|   2 +
 lib/librte_mempool/rte_mempool.c   |  66 +++-
 lib/librte_mempool/rte_mempool.h   | 251 ++---
 lib/librte_mempool/rte_mempool_ops.c   | 148 +
 lib/librte_mempool/rte_mempool_ring.c  | 161 ++
 lib/librte_mempool/rte_mempool_version.map |  13 +-
 9 files changed, 601 insertions(+), 81 deletions(-)
 create mode 100644 lib/librte_mempool/rte_mempool_ops.c
 create mode 100644 lib/librte_mempool/rte_mempool_ring.c

diff --git a/app/test/test_mempool_perf.c b/app/test/test_mempool_perf.c
index c5e3576..c5f8455 100644
--- a/app/test/test_mempool_perf.c
+++ b/app/test/test_mempool_perf.c
@@ -161,7 +161,6 @@ per_lcore_mempool_test(__attribute__((unused)) void *arg)
   n_get_bulk);
if (unlikely(ret < 0)) {
rte_mempool_dump(stdout, mp);
-   rte_ring_dump(stdout, mp->ring);
/* in this case, objects are lost... */
return -1;
}
diff --git a/doc/guides/prog_guide/mempool_lib.rst 
b/doc/guides/prog_guide/mempool_lib.rst
index c3afc2e..2e3116e 100644
--- a/doc/guides/prog_guide/mempool_lib.rst
+++ b/doc/guides/prog_guide/mempool_lib.rst
@@ -34,7 +34,7 @@ Mempool Library
 ===

 A memory pool is an allocator of a fixed-sized object.
-In the DPDK, it is identified by name and uses a ring to store free objects.
+In the DPDK, it is identified by name and uses a ring or an external mempool 
manager to store free objects.
 It provides some other optional services such as a per-core object cache and
 an alignment helper to ensure that objects are padded to spread them equally 
on all DRAM or DDR3 channels.

@@ -127,6 +127,35 @@ The maximum size of the cache is static and is defined at 
compilation time (CONF
A mempool in Memory with its Associated Ring


+External Mempool Manager
+
+
+This allows external memory subsystems, such as external hardware memory
+management systems and software based memory allocators, to be used with DPDK.
+
+There are two aspects to external mempool manager.
+
+* Adding the code for your new mempool operations (ops). This is achieved by
+  adding a new mempool ops code, and using the ``REGISTER_MEMPOOL_OPS`` macro.
+
+* Using the new API to call ``rte_mempool_create_empty()`` and
+  ``rte_mempool_set_ops_byname()`` to create a new mempool and specifying which
+  ops to use.
+
+Several external mempool managers may be used in the same application. A new
+mempool can be created by using the ``rte_mempool_create_empty()`` function,
+then using ``rte_mempool_set_ops_byname()`` to point the mempool to the
+relevant mempool manager callback (ops) structure.
+
+Legacy applications may continue to use the old ``rte_mempool_create()`` API
+call, which uses a ring based mempool manager by default. These applications
+will need to be modified to use a new external mempool manager.
+
+For applications that use ``rte_pktmbuf_create()``, there is a config setting
+(``RTE_MBUF_DEFAULT_MEMPOOL_OPS``) that allows the application to make use of
+an external mempool manager.
+
+
 Use Cases
 -

diff --git a/doc/guides/rel_notes/deprecation.rst 
b/doc/guides/rel_notes/deprecation.rst
index 7d947ae..c415095 100644
--- a/doc/guides/rel_notes/deprecation.rst
+++ b/doc/guides/rel_notes/deprecation.rst
@@ -39,15 +39,6 @@ Deprecation Notices
   compact API. The ones that remain are backwards compatible and use the
   per-lcore default cache if available. This change targets release 16.07.

-* The rte_mempool struct will be changed in 16.07 to facilitate the new
-  external mempool manager functionality.
-  The ring element will be replaced with a more generic 'pool' opaque pointer
-  to allow new mempool handlers to use their own user-defined mempool
-  layout. Also newly added to rte_mempool is a handler index.
-  The existing API will be backward compatible, but there will be new API
-  functions added to facilitate the creation of mempools using 

[dpdk-dev] [PATCH v3 00/30]

2016-06-15 Thread Beilei Xing
Update base driver for ixgbe, mainly work on
new features and bug fixes.

v3 changes:
 Fix some commit log issues.

Beilei Xing (30):
  ixgbe/base: add new VF requests for mailbox API
  ixgbe/base: add sgmii link for X550
  ixgbe/base: fix problematic return value
  ixgbe/base: add MAC link setup for X550a SFP
  ixgbe/base: fix checksum error of checking PHY token
  ixgbe/base: refactor eee setup for X550
  ixgbe/base: change access method
  ixgbe/base: add KR support for X550em_a devices
  ixgbe/base: add link MAC setup for X550a SFP+
  ixgbe/base: clear stale pool mappings
  ixgbe/base: rename macro of TDL
  ixgbe/base: fix error path to release lock
  ixgbe/base: fix for code style
  ixgbe/base: fix firmware commands on X550em_a
  ixgbe/base: refactor NW management interface ops
  ixgbe/base: add new phy definitions
  ixgbe/base: change device IDs
  ixgbe/base: add function to reset swfw semaphore
  ixgbe/base: fix possible race issue
  ixgbe/base: fix register access error
  ixgbe/base: limit PHY token accessing to MDIO only
  ixgbe/base: simplify add/remove VLANs
  ixgbe/base: add bypassing VLVF
  ixgbe/base: unify coding style
  ixgbe/base: use u8 to replace u16 for a variable
  ixgbe/base: fix endianness issues
  ixgbe/base: allow setting MAC anti spoofing per VF
  ixgbe/base: add flow control autoneg for X550a
  ixgbe/base: define if enable crosstalk work around
  ixgbe/base: update README

 doc/guides/rel_notes/release_16_07.rst  |   11 +
 drivers/net/ixgbe/base/README   |2 +-
 drivers/net/ixgbe/base/ixgbe_82598.c|5 +-
 drivers/net/ixgbe/base/ixgbe_82598.h|3 +-
 drivers/net/ixgbe/base/ixgbe_82599.c|9 +-
 drivers/net/ixgbe/base/ixgbe_api.c  |   41 +-
 drivers/net/ixgbe/base/ixgbe_api.h  |8 +-
 drivers/net/ixgbe/base/ixgbe_common.c   |  361 ---
 drivers/net/ixgbe/base/ixgbe_common.h   |9 +-
 drivers/net/ixgbe/base/ixgbe_mbx.h  |4 +-
 drivers/net/ixgbe/base/ixgbe_osdep.h|1 +
 drivers/net/ixgbe/base/ixgbe_phy.c  |   16 +-
 drivers/net/ixgbe/base/ixgbe_phy.h  |3 +
 drivers/net/ixgbe/base/ixgbe_type.h |  118 ++-
 drivers/net/ixgbe/base/ixgbe_vf.c   |   10 +-
 drivers/net/ixgbe/base/ixgbe_vf.h   |7 +-
 drivers/net/ixgbe/base/ixgbe_x540.c |   29 +-
 drivers/net/ixgbe/base/ixgbe_x540.h |1 +
 drivers/net/ixgbe/base/ixgbe_x550.c | 1156 +++
 drivers/net/ixgbe/base/ixgbe_x550.h |   52 +
 drivers/net/ixgbe/ixgbe_ethdev.c|   11 +-
 drivers/net/ixgbe/ixgbe_pf.c|2 +-
 lib/librte_eal/common/include/rte_pci_dev_ids.h |   12 +-
 23 files changed, 1456 insertions(+), 415 deletions(-)

Acked-by: Helin Zhang 
-- 
2.5.0



[dpdk-dev] [PATCH v3 01/30] ixgbe/base: add new VF requests for mailbox API

2016-06-15 Thread Beilei Xing
It adds two new VF requests of IXGBE_VF_GET_RETA and
IXGBE_VF_GET_RSS_KEY for mailbox API.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_mbx.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_mbx.h 
b/drivers/net/ixgbe/base/ixgbe_mbx.h
index 4a120a3..d775142 100644
--- a/drivers/net/ixgbe/base/ixgbe_mbx.h
+++ b/drivers/net/ixgbe/base/ixgbe_mbx.h
@@ -109,7 +109,9 @@ enum ixgbe_pfvf_api_rev {
 #define IXGBE_VF_GET_QUEUES0x09 /* get queue configuration */

 /* mailbox API, version 1.2 VF requests */
-#define IXGBE_VF_UPDATE_XCAST_MODE 0x0C
+#define IXGBE_VF_GET_RETA  0x0a /* VF request for RETA */
+#define IXGBE_VF_GET_RSS_KEY   0x0b /* get RSS key */
+#define IXGBE_VF_UPDATE_XCAST_MODE 0x0C

 /* GET_QUEUES return data indices within the mailbox */
 #define IXGBE_VF_TX_QUEUES 1   /* number of Tx queues supported */
-- 
2.5.0



[dpdk-dev] [PATCH v3 02/30] ixgbe/base: add sgmii link for X550

2016-06-15 Thread Beilei Xing
It adds sgmii link for X550.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h |   9 +++
 drivers/net/ixgbe/base/ixgbe_x550.c | 127 +---
 2 files changed, 127 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 4dce2ac..493bd46 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3511,6 +3511,8 @@ enum ixgbe_phy_type {
ixgbe_phy_qsfp_intel,
ixgbe_phy_qsfp_unknown,
ixgbe_phy_sfp_unsupported, /*Enforce bit set with unsupported module*/
+   ixgbe_phy_sgmii,
+   ixgbe_phy_m88,
ixgbe_phy_generic
 };

@@ -3554,6 +3556,7 @@ enum ixgbe_media_type {
ixgbe_media_type_fiber_lco,
ixgbe_media_type_copper,
ixgbe_media_type_backplane,
+   ixgbe_media_type_sgmii,
ixgbe_media_type_cx4,
ixgbe_media_type_virtual
 };
@@ -4059,6 +4062,7 @@ struct ixgbe_hw {
 #define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P) ? 0x8010 : 0x4010)
 #define IXGBE_KRM_LINK_CTRL_1(P)   ((P) ? 0x820C : 0x420C)
 #define IXGBE_KRM_AN_CNTL_1(P) ((P) ? 0x822C : 0x422C)
+#define IXGBE_KRM_SGMII_CTRL(P)((P) ? 0x82A0 : 0x42A0)
 #define IXGBE_KRM_DSP_TXFFE_STATE_4(P) ((P) ? 0x8634 : 0x4634)
 #define IXGBE_KRM_DSP_TXFFE_STATE_5(P) ((P) ? 0x8638 : 0x4638)
 #define IXGBE_KRM_RX_TRN_LINKUP_CTRL(P)((P) ? 0x8B00 : 0x4B00)
@@ -4072,6 +4076,8 @@ struct ixgbe_hw {
 #define IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK(0x7 << 8)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_1G  (2 << 8)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_10G (4 << 8)
+#define IXGBE_KRM_LINK_CTRL_1_TETH_AN_SGMII_EN (1 << 12)
+#define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CLAUSE_37_EN (1 << 13)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_FEC_REQ  (1 << 14)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC  (1 << 15)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KX   (1 << 16)
@@ -4084,6 +4090,9 @@ struct ixgbe_hw {
 #define IXGBE_KRM_AN_CNTL_1_SYM_PAUSE  (1 << 28)
 #define IXGBE_KRM_AN_CNTL_1_ASM_PAUSE  (1 << 29)

+#define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D   (1 << 12)
+#define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D(1 << 19)
+
 #define IXGBE_KRM_DSP_TXFFE_STATE_C0_EN(1 << 6)
 #define IXGBE_KRM_DSP_TXFFE_STATE_CP1_CN1_EN   (1 << 15)
 #define IXGBE_KRM_DSP_TXFFE_STATE_CO_ADAPT_EN  (1 << 16)
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 0bbaa55..6c00b2a 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -329,6 +329,39 @@ STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_identify_phy_1g - Get 1g PHY type based on device id
+ * @hw: pointer to hardware structure
+ *
+ * Returns error code
+ */
+static s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
+{
+   u16 phy_id_high;
+   u16 phy_id_low;
+   u32 val = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+
+   hw->phy.addr = (val >> 3) & 0x1F;
+   val = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
+  hw->phy.addr, _id_high);
+   if (val || phy_id_high == 0x) {
+   hw->phy.type = ixgbe_phy_sgmii;
+   return 0;
+   }
+
+   val = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_LOW,
+  hw->phy.addr, _id_low);
+   if (val)
+   return val;
+
+   hw->phy.id = (u32)phy_id_high << 16;
+   hw->phy.id |= phy_id_low & IXGBE_PHY_REVISION_MASK;
+   hw->phy.revision = (u32)phy_id_low & ~IXGBE_PHY_REVISION_MASK;
+   hw->phy.type = ixgbe_phy_m88;
+
+   return 0;
+}
+
+/**
  * ixgbe_identify_phy_x550em - Get PHY type based on device id
  * @hw: pointer to hardware structure
  *
@@ -364,10 +397,11 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
break;
case IXGBE_DEV_ID_X550EM_X_1G_T:
case IXGBE_DEV_ID_X550EM_X_10G_T:
-   case IXGBE_DEV_ID_X550EM_A_1G_T:
-   case IXGBE_DEV_ID_X550EM_A_1G_T_L:
case IXGBE_DEV_ID_X550EM_A_10G_T:
return ixgbe_identify_phy_generic(hw);
+   case IXGBE_DEV_ID_X550EM_A_1G_T:
+   case IXGBE_DEV_ID_X550EM_A_1G_T_L:
+   return ixgbe_identify_phy_1g(hw);
default:
break;
}
@@ -1286,11 +1320,14 @@ enum ixgbe_media_type 
ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
break;
case IXGBE_DEV_ID_X550EM_X_1G_T:
case IXGBE_DEV_ID_X550EM_X_10G_T:
-   case IXGBE_DEV_ID_X550EM_A_1G_T:
-   case IXGBE_DEV_ID_X550EM_A_1G_T_L:
case IXGBE_DEV_ID_X550EM_A_10G_T:
media_type = ixgbe_media_type_copper;
break;
+   case IXGBE_DEV_ID_X550EM_A_1G_T:
+   case IXGBE_DEV_ID_X550EM_A_1G_T_L:
+

[dpdk-dev] [PATCH v3 03/30] ixgbe/base: fix problematic return value

2016-06-15 Thread Beilei Xing
An error code indicating that the PF rejects the MAC address change
should be returned, in case that the PF has already assigned a MAC
for the VF.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_vf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_vf.c 
b/drivers/net/ixgbe/base/ixgbe_vf.c
index 40dc1c8..81ea6c7 100644
--- a/drivers/net/ixgbe/base/ixgbe_vf.c
+++ b/drivers/net/ixgbe/base/ixgbe_vf.c
@@ -362,8 +362,10 @@ s32 ixgbe_set_rar_vf(struct ixgbe_hw *hw, u32 index, u8 
*addr, u32 vmdq,

/* if nacked the address was rejected, use "perm_addr" */
if (!ret_val &&
-   (msgbuf[0] == (IXGBE_VF_SET_MAC_ADDR | IXGBE_VT_MSGTYPE_NACK)))
+   (msgbuf[0] == (IXGBE_VF_SET_MAC_ADDR | IXGBE_VT_MSGTYPE_NACK))) {
ixgbe_get_mac_addr_vf(hw, hw->mac.addr);
+   return IXGBE_ERR_MBX;
+   }

return ret_val;
 }
-- 
2.5.0



[dpdk-dev] [PATCH v3 05/30] ixgbe/base: fix checksum error of checking PHY token

2016-06-15 Thread Beilei Xing
This patch sets the Host Interface PHY token command
checksum to the checksum default of 0xFF, therefore
the checksum is not checked by the firmware. Otherwise
the command fails with a checksum failed error.

Fixes: 86b8fb293fdf ("ixgbe/base: add sw-firmware sync for resource sharing on 
X550em_a")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 8a5b1dc..36df3c3 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1041,6 +1041,7 @@ s32 ixgbe_get_phy_token(struct ixgbe_hw *hw)
token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
+   token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
token_cmd.port_number = hw->bus.lan_id;
token_cmd.command_type = FW_PHY_TOKEN_REQ;
token_cmd.pad = 0;
@@ -1071,6 +1072,7 @@ s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
token_cmd.hdr.cmd = FW_PHY_TOKEN_REQ_CMD;
token_cmd.hdr.buf_len = FW_PHY_TOKEN_REQ_LEN;
token_cmd.hdr.cmd_or_resp.cmd_resv = 0;
+   token_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
token_cmd.port_number = hw->bus.lan_id;
token_cmd.command_type = FW_PHY_TOKEN_REL;
token_cmd.pad = 0;
-- 
2.5.0



[dpdk-dev] [PATCH v3 09/30] ixgbe/base: add link MAC setup for X550a SFP+

2016-06-15 Thread Beilei Xing
This patch updates ixgbe_setup_mac_link_sfp_x550a for X550 SFP+.
ixgbe_set_lan_id_multi_port_pcie has been updated to set the MAC
instance(0/1) which is needed when configuring the external PHY,
since X550a has two instances of MGPK. The MAC instance is read
from the EEPROM.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 13 +-
 drivers/net/ixgbe/base/ixgbe_phy.h|  3 ++
 drivers/net/ixgbe/base/ixgbe_type.h   |  8 
 drivers/net/ixgbe/base/ixgbe_x550.c   | 85 ++-
 4 files changed, 86 insertions(+), 23 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index ec61408..82a8416 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -1020,13 +1020,15 @@ s32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw)
  *  ixgbe_set_lan_id_multi_port_pcie - Set LAN id for PCIe multiple port 
devices
  *  @hw: pointer to the HW structure
  *
- *  Determines the LAN function id by reading memory-mapped registers
- *  and swaps the port value if requested.
+ *  Determines the LAN function id by reading memory-mapped registers and swaps
+ *  the port value if requested, and set MAC instance for devices that share
+ *  CS4227.
  **/
 void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw)
 {
struct ixgbe_bus_info *bus = >bus;
u32 reg;
+   u16 ee_ctrl_4;

DEBUGFUNC("ixgbe_set_lan_id_multi_port_pcie");

@@ -1038,6 +1040,13 @@ void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw 
*hw)
reg = IXGBE_READ_REG(hw, IXGBE_FACTPS_BY_MAC(hw));
if (reg & IXGBE_FACTPS_LFS)
bus->func ^= 0x1;
+
+   /* Get MAC instance from EEPROM for configuring CS4227 */
+   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP) {
+   hw->eeprom.ops.read(hw, IXGBE_EEPROM_CTRL_4, _ctrl_4);
+   bus->instance_id = (ee_ctrl_4 & IXGBE_EE_CTRL_4_INST_ID) >>
+   IXGBE_EE_CTRL_4_INST_ID_SHIFT;
+   }
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_phy.h 
b/drivers/net/ixgbe/base/ixgbe_phy.h
index 1a5affe..281f9fa 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.h
+++ b/drivers/net/ixgbe/base/ixgbe_phy.h
@@ -89,8 +89,11 @@ POSSIBILITY OF SUCH DAMAGE.

 #define IXGBE_CS4227   0xBE/* CS4227 address */
 #define IXGBE_CS4227_GLOBAL_ID_LSB 0
+#define IXGBE_CS4227_GLOBAL_ID_MSB 1
 #define IXGBE_CS4227_SCRATCH   2
 #define IXGBE_CS4227_GLOBAL_ID_VALUE   0x03E5
+#define IXGBE_CS4223_PHY_ID0x7003/* Quad port */
+#define IXGBE_CS4227_PHY_ID0x3003/* Dual port */
 #define IXGBE_CS4227_RESET_PENDING 0x1357
 #define IXGBE_CS4227_RESET_COMPLETE0x5AA5
 #define IXGBE_CS4227_RETRIES   15
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 7bd6f2c..0a35891 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -1472,6 +1472,7 @@ struct ixgbe_dmac_config {
 #define IXGBE_CORECTL_WRITE_CMD0x0001

 /* Device Type definitions for new protocol MDIO commands */
+#define IXGBE_MDIO_ZERO_DEV_TYPE   0x0
 #define IXGBE_MDIO_PMA_PMD_DEV_TYPE0x1
 #define IXGBE_MDIO_PCS_DEV_TYPE0x3
 #define IXGBE_MDIO_PHY_XS_DEV_TYPE 0x4
@@ -2247,6 +2248,9 @@ enum {
 #define IXGBE_PBANUM_PTR_GUARD 0xFAFA
 #define IXGBE_EEPROM_CHECKSUM  0x3F
 #define IXGBE_EEPROM_SUM   0xBABA
+#define IXGBE_EEPROM_CTRL_40x45
+#define IXGBE_EE_CTRL_4_INST_ID0x10
+#define IXGBE_EE_CTRL_4_INST_ID_SHIFT  4
 #define IXGBE_PCIE_ANALOG_PTR  0x03
 #define IXGBE_ATLAS0_CONFIG_PTR0x04
 #define IXGBE_PHY_PTR  0x04
@@ -3630,6 +3634,7 @@ struct ixgbe_bus_info {

u16 func;
u16 lan_id;
+   u16 instance_id;
 };

 /* Flow control parameters */
@@ -4130,5 +4135,8 @@ struct ixgbe_hw {

 #define IXGBE_NW_MNG_IF_SEL0x00011178
 #define IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE (1 << 24)
+#define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT 3
+#define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD   \
+   (0x1F << IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT)

 #endif /* _IXGBE_TYPE_H_ */
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 1ae79f5..0bb3436 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1550,7 +1550,8 @@ void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
mac->ops.set_rate_select_speed =
ixgbe_set_soft_rate_select_speed;
-   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N)
+   if ((hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) ||
+   (hw->device_id == 

[dpdk-dev] [PATCH v3 08/30] ixgbe/base: add KR support for X550em_a devices

2016-06-15 Thread Beilei Xing
Implement KR support for X550em_a devices.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 51 +
 1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 40060c0..1ae79f5 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -564,9 +564,14 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
else
mac->ops.setup_fc = ixgbe_setup_fc_X550em;

-
-   if (hw->device_id != IXGBE_DEV_ID_X550EM_X_KR)
+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_X_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR_L:
+   break;
+   default:
mac->ops.setup_eee = NULL;
+   }

/* PHY */
phy->ops.init = ixgbe_init_phy_ops_X550em;
@@ -773,11 +778,16 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
  IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  autoneg_eee_reg);
-   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+   return IXGBE_SUCCESS;
+   }

+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_X_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR_L:
status = hw->mac.ops.read_iosf_sb_reg(hw,
-IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
if (status != IXGBE_SUCCESS)
return status;

@@ -788,10 +798,13 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;

status = hw->mac.ops.write_iosf_sb_reg(hw,
- IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
- IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
+  IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+  IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
if (status != IXGBE_SUCCESS)
return status;
+   break;
+   default:
+   break;
}

return IXGBE_SUCCESS;
@@ -820,7 +833,13 @@ static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
  IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  autoneg_eee_reg);
-   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+   return IXGBE_SUCCESS;
+   }
+
+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_X_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR_L:
status = hw->mac.ops.read_iosf_sb_reg(hw,
 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
 IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
@@ -838,6 +857,9 @@ static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
  IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
if (status != IXGBE_SUCCESS)
return status;
+   break;
+   default:
+   break;
}

return IXGBE_SUCCESS;
@@ -2085,10 +2107,13 @@ s32 ixgbe_init_ext_t_x550em(struct ixgbe_hw *hw)
  *  ixgbe_setup_kr_x550em - Configure the KR PHY.
  *  @hw: pointer to hardware structure
  *
- *  Configures the integrated KR PHY.
+ *  Configures the integrated KR PHY for X550EM_x.
  **/
 s32 ixgbe_setup_kr_x550em(struct ixgbe_hw *hw)
 {
+   if (hw->mac.type != ixgbe_mac_X550EM_x)
+   return IXGBE_SUCCESS;
+
return ixgbe_setup_kr_speed_x550em(hw, hw->phy.autoneg_advertised);
 }

@@ -3356,7 +3381,10 @@ s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)
goto out;
}

-   if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+   switch (hw->device_id) {
+   case IXGBE_DEV_ID_X550EM_X_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR:
+   case IXGBE_DEV_ID_X550EM_A_KR_L:
ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
   IXGBE_KRM_AN_CNTL_1(hw->bus.lan_id),
   IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
@@ -3374,6 +3402,9 @@ s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw)

/* This device does not fully support AN. */
hw->fc.disable_fc_autoneg = true;
+   break;
+   default:
+   break;
}

 out:
-- 
2.5.0



[dpdk-dev] [PATCH v3 06/30] ixgbe/base: refactor eee setup for X550

2016-06-15 Thread Beilei Xing
Break ixgbe_setup_eee_X550 down to better handle a change from if
statements to switch statements needed to add X550em_a KR support.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 174 ++--
 1 file changed, 105 insertions(+), 69 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 36df3c3..78672a6 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -751,6 +751,99 @@ s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_enable_eee_x550 - Enable EEE support
+ * @hw: pointer to hardware structure
+ */
+static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
+{
+   u16 autoneg_eee_reg;
+   u32 link_reg;
+   s32 status;
+
+   if (hw->mac.type == ixgbe_mac_X550) {
+   /* Advertise EEE capability */
+   hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+_eee_reg);
+
+   autoneg_eee_reg |= (IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
+   IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
+   IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
+
+   hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ autoneg_eee_reg);
+   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+
+   status = ixgbe_read_iosf_sb_reg_x550(hw,
+IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
+   if (status != IXGBE_SUCCESS)
+   return status;
+
+   link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
+   IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX;
+
+   /* Don't advertise FEC capability when EEE enabled. */
+   link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
+
+   status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
+   if (status != IXGBE_SUCCESS)
+   return status;
+   }
+
+   return IXGBE_SUCCESS;
+}
+
+/**
+ * ixgbe_disable_eee_x550 - Disable EEE support
+ * @hw: pointer to hardware structure
+ */
+static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
+{
+   u16 autoneg_eee_reg;
+   u32 link_reg;
+   s32 status;
+
+   if (hw->mac.type == ixgbe_mac_X550) {
+   /* Disable advertised EEE capability */
+   hw->phy.ops.read_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+_eee_reg);
+
+   autoneg_eee_reg &= ~(IXGBE_AUTO_NEG_10GBASE_EEE_ADVT |
+IXGBE_AUTO_NEG_1000BASE_EEE_ADVT |
+IXGBE_AUTO_NEG_100BASE_EEE_ADVT);
+
+   hw->phy.ops.write_reg(hw, IXGBE_MDIO_AUTO_NEG_EEE_ADVT,
+ IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
+ autoneg_eee_reg);
+   } else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
+   status = ixgbe_read_iosf_sb_reg_x550(hw,
+IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
+   if (status != IXGBE_SUCCESS)
+   return status;
+
+   link_reg &= ~(IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR |
+ IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX);
+
+   /* Advertise FEC capability when EEE is disabled. */
+   link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;
+
+   status = ixgbe_write_iosf_sb_reg_x550(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
+   if (status != IXGBE_SUCCESS)
+   return status;
+   }
+
+   return IXGBE_SUCCESS;
+}
+
+/**
  *  ixgbe_setup_eee_X550 - Enable/disable EEE support
  *  @hw: pointer to the HW structure
  *  @enable_eee: boolean flag to enable EEE
@@ -762,10 +855,8 @@ s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
  **/
 s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool enable_eee)
 {
-   u32 eeer;
-   u16 autoneg_eee_reg;
-   u32 link_reg;
s32 status;
+   u32 eeer;

DEBUGFUNC("ixgbe_setup_eee_X550");

@@ -774,75 +865,20 @@ s32 ixgbe_setup_eee_X550(struct ixgbe_hw *hw, bool 
enable_eee)
if (enable_eee) {
eeer |= (IXGBE_EEER_TX_LPI_EN | 

[dpdk-dev] [PATCH v3 10/30] ixgbe/base: clear stale pool mappings

2016-06-15 Thread Beilei Xing
This patch adds clearing the pool mappings when configuring default
MAC addresses for the interface. Without this there will be the risk
of leaking an address into pool 0 which really belongs to VF 0 when
SR-IOV is enabled.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_82599.c  | 9 ++---
 drivers/net/ixgbe/base/ixgbe_common.c | 7 ---
 drivers/net/ixgbe/base/ixgbe_x540.c   | 9 ++---
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_82599.c 
b/drivers/net/ixgbe/base/ixgbe_82599.c
index 154c1f1..5bc7c2b 100644
--- a/drivers/net/ixgbe/base/ixgbe_82599.c
+++ b/drivers/net/ixgbe/base/ixgbe_82599.c
@@ -1176,11 +1176,14 @@ mac_reset_top:

/* Add the SAN MAC address to the RAR only if it's a valid address */
if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
-   hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
-   hw->mac.san_addr, 0, IXGBE_RAH_AV);
-
/* Save the SAN MAC RAR index */
hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1;
+   hw->mac.ops.set_rar(hw, hw->mac.san_mac_rar_index,
+   hw->mac.san_addr, 0, IXGBE_RAH_AV);
+
+   /* clear VMDq pool/queue selection for this RAR */
+   hw->mac.ops.clear_vmdq(hw, hw->mac.san_mac_rar_index,
+  IXGBE_CLEAR_VMDQ_ALL);

/* Reserve the last RAR for the SAN MAC address */
hw->mac.num_rar_entries--;
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 82a8416..d211303 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -2406,10 +2406,11 @@ s32 ixgbe_init_rx_addrs_generic(struct ixgbe_hw *hw)
  hw->mac.addr[4], hw->mac.addr[5]);

hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
-
-   /* clear VMDq pool/queue selection for RAR 0 */
-   hw->mac.ops.clear_vmdq(hw, 0, IXGBE_CLEAR_VMDQ_ALL);
}
+
+   /* clear VMDq pool/queue selection for RAR 0 */
+   hw->mac.ops.clear_vmdq(hw, 0, IXGBE_CLEAR_VMDQ_ALL);
+
hw->addr_ctrl.overflow_promisc = 0;

hw->addr_ctrl.rar_used_count = 1;
diff --git a/drivers/net/ixgbe/base/ixgbe_x540.c 
b/drivers/net/ixgbe/base/ixgbe_x540.c
index 9ade1b5..0678913 100644
--- a/drivers/net/ixgbe/base/ixgbe_x540.c
+++ b/drivers/net/ixgbe/base/ixgbe_x540.c
@@ -268,11 +268,14 @@ mac_reset_top:

/* Add the SAN MAC address to the RAR only if it's a valid address */
if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
-   hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
-   hw->mac.san_addr, 0, IXGBE_RAH_AV);
-
/* Save the SAN MAC RAR index */
hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1;
+   hw->mac.ops.set_rar(hw, hw->mac.san_mac_rar_index,
+   hw->mac.san_addr, 0, IXGBE_RAH_AV);
+
+   /* clear VMDq pool/queue selection for this RAR */
+   hw->mac.ops.clear_vmdq(hw, hw->mac.san_mac_rar_index,
+  IXGBE_CLEAR_VMDQ_ALL);

/* Reserve the last RAR for the SAN MAC address */
hw->mac.num_rar_entries--;
-- 
2.5.0



[dpdk-dev] [PATCH v3 11/30] ixgbe/base: rename macro of TDL

2016-06-15 Thread Beilei Xing
This patch renames IXGBE_PVFTTDLEN to IXGBE_PVFTDLEN according to
abbreviation of Transmit Descriptor Length in datasheet.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 0a35891..de295e1 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -2824,7 +2824,7 @@ enum {
 #define IXGBE_PVFPSRTYPE(P)(0x0EA00 + (4 * (P)))
 #define IXGBE_PVFTDBAL(P)  (0x06000 + (0x40 * (P)))
 #define IXGBE_PVFTDBAH(P)  (0x06004 + (0x40 * (P)))
-#define IXGBE_PVFTTDLEN(P) (0x06008 + (0x40 * (P)))
+#define IXGBE_PVFTDLEN(P)  (0x06008 + (0x40 * (P)))
 #define IXGBE_PVFTDH(P)(0x06010 + (0x40 * (P)))
 #define IXGBE_PVFTDT(P)(0x06018 + (0x40 * (P)))
 #define IXGBE_PVFTXDCTL(P) (0x06028 + (0x40 * (P)))
-- 
2.5.0



[dpdk-dev] [PATCH v3 04/30] ixgbe/base: add MAC link setup for X550a SFP

2016-06-15 Thread Beilei Xing
This patch adds ixgbe_setup_mac_link_sfp_x550a for X550a SFP.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h |  4 +++
 drivers/net/ixgbe/base/ixgbe_x550.c | 64 -
 drivers/net/ixgbe/base/ixgbe_x550.h |  3 ++
 3 files changed, 70 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 493bd46..7bd6f2c 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -4062,6 +4062,7 @@ struct ixgbe_hw {
 #define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P) ? 0x8010 : 0x4010)
 #define IXGBE_KRM_LINK_CTRL_1(P)   ((P) ? 0x820C : 0x420C)
 #define IXGBE_KRM_AN_CNTL_1(P) ((P) ? 0x822C : 0x422C)
+#define IXGBE_KRM_AN_CNTL_8(P) ((P) ? 0x8248 : 0x4248)
 #define IXGBE_KRM_SGMII_CTRL(P)((P) ? 0x82A0 : 0x42A0)
 #define IXGBE_KRM_DSP_TXFFE_STATE_4(P) ((P) ? 0x8634 : 0x4634)
 #define IXGBE_KRM_DSP_TXFFE_STATE_5(P) ((P) ? 0x8638 : 0x4638)
@@ -4090,6 +4091,9 @@ struct ixgbe_hw {
 #define IXGBE_KRM_AN_CNTL_1_SYM_PAUSE  (1 << 28)
 #define IXGBE_KRM_AN_CNTL_1_ASM_PAUSE  (1 << 29)

+#define IXGBE_KRM_AN_CNTL_8_LINEAR (1 << 0)
+#define IXGBE_KRM_AN_CNTL_8_LIMITING   (1 << 1)
+
 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D   (1 << 12)
 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D(1 << 19)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 6c00b2a..8a5b1dc 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1488,9 +1488,14 @@ void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
mac->ops.enable_tx_laser = NULL;
mac->ops.flap_tx_laser = NULL;
mac->ops.setup_link = ixgbe_setup_mac_link_multispeed_fiber;
-   mac->ops.setup_mac_link = ixgbe_setup_mac_link_sfp_x550em;
mac->ops.set_rate_select_speed =
ixgbe_set_soft_rate_select_speed;
+   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SFP_N)
+   mac->ops.setup_mac_link =
+   ixgbe_setup_mac_link_sfp_x550a;
+   else
+   mac->ops.setup_mac_link =
+   ixgbe_setup_mac_link_sfp_x550em;
break;
case ixgbe_media_type_copper:
mac->ops.setup_link = ixgbe_setup_mac_link_t_X550em;
@@ -2128,6 +2133,63 @@ s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
 }

 /**
+ *  ixgbe_setup_mac_link_sfp_x550a - Setup internal PHY for SFP
+ *  @hw: pointer to hardware structure
+ *
+ *  Configure the the integrated PHY for SFP support.
+ **/
+s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
+  ixgbe_link_speed speed,
+  bool autoneg_wait_to_complete)
+{
+   s32 ret_val;
+   u32 reg_val;
+   bool setup_linear = false;
+
+   UNREFERENCED_1PARAMETER(autoneg_wait_to_complete);
+
+   /* Check if SFP module is supported and linear */
+   ret_val = ixgbe_supported_sfp_modules_X550em(hw, _linear);
+
+   /* If no SFP module present, then return success. Return success since
+* SFP not present error is not excepted in the setup MAC link flow.
+*/
+   if (ret_val == IXGBE_ERR_SFP_NOT_PRESENT)
+   return IXGBE_SUCCESS;
+
+   if (ret_val != IXGBE_SUCCESS)
+   return ret_val;
+
+   /* Configure internal PHY for native SFI */
+   ret_val = hw->mac.ops.read_iosf_sb_reg(hw,
+  IXGBE_KRM_AN_CNTL_8(hw->bus.lan_id),
+  IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
+
+   if (ret_val != IXGBE_SUCCESS)
+   return ret_val;
+
+   if (setup_linear) {
+   reg_val &= ~IXGBE_KRM_AN_CNTL_8_LIMITING;
+   reg_val |= IXGBE_KRM_AN_CNTL_8_LINEAR;
+   } else {
+   reg_val |= IXGBE_KRM_AN_CNTL_8_LIMITING;
+   reg_val &= ~IXGBE_KRM_AN_CNTL_8_LINEAR;
+   }
+
+   ret_val = hw->mac.ops.write_iosf_sb_reg(hw,
+   IXGBE_KRM_AN_CNTL_8(hw->bus.lan_id),
+   IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+
+   if (ret_val != IXGBE_SUCCESS)
+   return ret_val;
+
+   /* Setup XFI/SFI internal link. */
+   ret_val = ixgbe_setup_ixfi_x550em(hw, );
+
+   return ret_val;
+}
+
+/**
  *  ixgbe_setup_ixfi_x550em_x - MAC specific iXFI configuration
  *  @hw: pointer to hardware structure
  *
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.h 
b/drivers/net/ixgbe/base/ixgbe_x550.h
index a8c0a67..2966c7b 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.h
+++ b/drivers/net/ixgbe/base/ixgbe_x550.h
@@ -100,6 +100,9 @@ s32 ixgbe_setup_fc_X550em(struct ixgbe_hw *hw);
 s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,

[dpdk-dev] [PATCH v3 13/30] ixgbe/base: fix for code style

2016-06-15 Thread Beilei Xing
The ixgbe_vf.h file did not use __ and instead used
 which is not the standard used in every other file.

Fixes: af75078fece3 ("first public release")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_vf.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_vf.h 
b/drivers/net/ixgbe/base/ixgbe_vf.h
index 411152a..9be2cda 100644
--- a/drivers/net/ixgbe/base/ixgbe_vf.h
+++ b/drivers/net/ixgbe/base/ixgbe_vf.h
@@ -31,8 +31,8 @@ POSSIBILITY OF SUCH DAMAGE.

 ***/

-#ifndef __IXGBE_VF_H__
-#define __IXGBE_VF_H__
+#ifndef _IXGBE_VF_H_
+#define _IXGBE_VF_H_

 #define IXGBE_VF_IRQ_CLEAR_MASK7
 #define IXGBE_VF_MAX_TX_QUEUES 8
-- 
2.5.0



[dpdk-dev] [PATCH v3 14/30] ixgbe/base: fix firmware commands on X550em_a

2016-06-15 Thread Beilei Xing
This patch fixes firmware commands on X550em_a. For one thing,
the checksum value was not being set.

Fixes: 0790adeb5675 ("ixgbe/base: support X550em_a device")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index e91546c..aaf6572 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1154,23 +1154,24 @@ s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
  *  @data: Data to write to the register
  **/
 s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
-   u32 device_type, u32 data)
+ u32 device_type, u32 data)
 {
struct ixgbe_hic_internal_phy_req write_cmd;
s32 status;
UNREFERENCED_1PARAMETER(device_type);

+   memset(_cmd, 0, sizeof(write_cmd));
write_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
write_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
+   write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
write_cmd.port_number = hw->bus.lan_id;
write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
write_cmd.address = (u16)reg_addr;
-   write_cmd.rsv1 = 0;
write_cmd.write_data = data;
-   write_cmd.pad = 0;

status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
-   sizeof(write_cmd), IXGBE_HI_COMMAND_TIMEOUT, false);
+ sizeof(write_cmd),
+ IXGBE_HI_COMMAND_TIMEOUT, false);

return status;
 }
@@ -1184,23 +1185,23 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
  *  @data: Pointer to read data from the register
  **/
 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
-   u32 device_type, u32 *data)
+u32 device_type, u32 *data)
 {
struct ixgbe_hic_internal_phy_req read_cmd;
s32 status;
UNREFERENCED_1PARAMETER(device_type);

+   memset(_cmd, 0, sizeof(read_cmd));
read_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
read_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
+   read_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
read_cmd.port_number = hw->bus.lan_id;
read_cmd.command_type = FW_INT_PHY_REQ_READ;
read_cmd.address = (u16)reg_addr;
-   read_cmd.rsv1 = 0;
-   read_cmd.write_data = 0;
-   read_cmd.pad = 0;

status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
-   sizeof(read_cmd), IXGBE_HI_COMMAND_TIMEOUT, true);
+ sizeof(read_cmd),
+ IXGBE_HI_COMMAND_TIMEOUT, true);

/* Extract the register value from the response. */
*data = ((struct ixgbe_hic_internal_phy_resp *)_cmd)->read_data;
-- 
2.5.0



[dpdk-dev] [PATCH v3 07/30] ixgbe/base: change access method

2016-06-15 Thread Beilei Xing
Use the method pointers instead of direct function calls so that
the right thing will happen on X550EM_a.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 84 ++---
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 78672a6..40060c0 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -546,8 +546,8 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)
link->addr = IXGBE_CS4227;
}
if (hw->mac.type == ixgbe_mac_X550EM_a) {
-   mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550a;
-   mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550a;
+   mac->ops.read_iosf_sb_reg = ixgbe_read_iosf_sb_reg_x550;
+   mac->ops.write_iosf_sb_reg = ixgbe_write_iosf_sb_reg_x550;
mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X550a;
mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X550a;
}
@@ -775,7 +775,7 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
  autoneg_eee_reg);
} else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {

-   status = ixgbe_read_iosf_sb_reg_x550(hw,
+   status = hw->mac.ops.read_iosf_sb_reg(hw,
 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
 IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
if (status != IXGBE_SUCCESS)
@@ -787,7 +787,7 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
/* Don't advertise FEC capability when EEE enabled. */
link_reg &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;

-   status = ixgbe_write_iosf_sb_reg_x550(hw,
+   status = hw->mac.ops.write_iosf_sb_reg(hw,
  IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
if (status != IXGBE_SUCCESS)
@@ -821,7 +821,7 @@ static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
  IXGBE_MDIO_AUTO_NEG_DEV_TYPE,
  autoneg_eee_reg);
} else if (hw->device_id == IXGBE_DEV_ID_X550EM_X_KR) {
-   status = ixgbe_read_iosf_sb_reg_x550(hw,
+   status = hw->mac.ops.read_iosf_sb_reg(hw,
 IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
 IXGBE_SB_IOSF_TARGET_KR_PHY, _reg);
if (status != IXGBE_SUCCESS)
@@ -833,7 +833,7 @@ static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
/* Advertise FEC capability when EEE is disabled. */
link_reg |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_FEC;

-   status = ixgbe_write_iosf_sb_reg_x550(hw,
+   status = hw->mac.ops.write_iosf_sb_reg(hw,
  IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
  IXGBE_SB_IOSF_TARGET_KR_PHY, link_reg);
if (status != IXGBE_SUCCESS)
@@ -1791,9 +1791,9 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,
s32 status;
u32 reg_val;

-   status = ixgbe_read_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-   IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
+   status = hw->mac.ops.read_iosf_sb_reg(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
if (status)
return status;

@@ -1811,9 +1811,9 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,

/* Restart auto-negotiation. */
reg_val |= IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART;
-   status = ixgbe_write_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-   IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);
+   status = hw->mac.ops.write_iosf_sb_reg(hw,
+  IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+  IXGBE_SB_IOSF_TARGET_KR_PHY, reg_val);

return status;
 }
@@ -2470,57 +2470,57 @@ s32 ixgbe_setup_phy_loopback_x550em(struct ixgbe_hw *hw)
u32 reg_val;

/* Disable AN and force speed to 10G Serial. */
-   status = ixgbe_read_iosf_sb_reg_x550(hw,
-   IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
-   IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
+   status = hw->mac.ops.read_iosf_sb_reg(hw,
+ IXGBE_KRM_LINK_CTRL_1(hw->bus.lan_id),
+ IXGBE_SB_IOSF_TARGET_KR_PHY, _val);
if (status != IXGBE_SUCCESS)
return status;
reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE;
reg_val &= ~IXGBE_KRM_LINK_CTRL_1_TETH_FORCE_SPEED_MASK;
reg_val |= 

[dpdk-dev] [PATCH v3 15/30] ixgbe/base: refactor NW management interface ops

2016-06-15 Thread Beilei Xing
This patch adds ixgbe_read_mng_if_sel_x550em to read NW_MNG_IF_SEL
register and save fields such as PHY MDIO_ADD.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h |  2 ++
 drivers/net/ixgbe/base/ixgbe_x550.c | 48 +++--
 2 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index de295e1..da1fe16 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -4134,6 +4134,8 @@ struct ixgbe_hw {
 #define IXGBE_SB_IOSF_TARGET_KR_PHY0

 #define IXGBE_NW_MNG_IF_SEL0x00011178
+#define IXGBE_NW_MNG_IF_SEL_MDIO_ACT   (1 << 1)
+#define IXGBE_NW_MNG_IF_SEL_ENABLE_10_100M (1 << 23)
 #define IXGBE_NW_MNG_IF_SEL_INT_PHY_MODE (1 << 24)
 #define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT 3
 #define IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD   \
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index aaf6572..993ef16 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -338,9 +338,8 @@ static s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
 {
u16 phy_id_high;
u16 phy_id_low;
-   u32 val = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+   u32 val;

-   hw->phy.addr = (val >> 3) & 0x1F;
val = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_ID_HIGH,
   hw->phy.addr, _id_high);
if (val || phy_id_high == 0x) {
@@ -1843,6 +1842,33 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,
 }

 /**
+ *  ixgbe_read_mng_if_sel_x550em - Read NW_MNG_IF_SEL register
+ *  @hw: pointer to hardware structure
+ *
+ *  Read NW_MNG_IF_SEL register and save field values, and check for valid 
field
+ *  values.
+ **/
+STATIC s32 ixgbe_read_mng_if_sel_x550em(struct ixgbe_hw *hw)
+{
+   /* Save NW management interface connected on board. This is used
+* to determine internal PHY mode.
+*/
+   hw->phy.nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
+
+   /* If X552 (X550EM_a) and MDIO is connected to external PHY, then set
+* PHY address. This register field was has only been used for X552.
+*/
+   if (hw->mac.type == ixgbe_mac_X550EM_a &&
+   hw->phy.nw_mng_if_sel & IXGBE_NW_MNG_IF_SEL_MDIO_ACT) {
+   hw->phy.addr = (hw->phy.nw_mng_if_sel &
+   IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD) >>
+   IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
+   }
+
+   return IXGBE_SUCCESS;
+}
+
+/**
  *  ixgbe_init_phy_ops_X550em - PHY/SFP specific init
  *  @hw: pointer to hardware structure
  *
@@ -1859,14 +1885,11 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)

hw->mac.ops.set_lan_id(hw);

+   ixgbe_read_mng_if_sel_x550em(hw);
+
if (hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) {
phy->phy_semaphore_mask = IXGBE_GSSR_SHARED_I2C_SM;
ixgbe_setup_mux_ctl(hw);
-
-   /* Save NW management interface connected on board. This is used
-* to determine internal PHY mode.
-*/
-   phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
phy->ops.identify_sfp = ixgbe_identify_sfp_module_X550em;
}

@@ -1893,11 +1916,6 @@ s32 ixgbe_init_phy_ops_X550em(struct ixgbe_hw *hw)
phy->ops.write_reg = ixgbe_write_phy_reg_x550em;
break;
case ixgbe_phy_x550em_ext_t:
-   /* Save NW management interface connected on board. This is used
-* to determine internal PHY mode
-*/
-   phy->nw_mng_if_sel = IXGBE_READ_REG(hw, IXGBE_NW_MNG_IF_SEL);
-
/* If internal link mode is XFI, then setup iXFI internal link,
 * else setup KR now.
 */
@@ -2256,12 +2274,6 @@ s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
/* Configure internal PHY for KR/KX. */
ixgbe_setup_kr_speed_x550em(hw, speed);

-   /* Get CS4227 MDIO address */
-   hw->phy.addr =
-   (hw->phy.nw_mng_if_sel &
-IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD)
-   >> IXGBE_NW_MNG_IF_SEL_MDIO_PHY_ADD_SHIFT;
-
if (hw->phy.addr == 0x0 || hw->phy.addr == 0x) {
/* Find Address */
DEBUGOUT("Invalid NW_MNG_IF_SEL.MDIO_PHY_ADD value\n");
-- 
2.5.0



[dpdk-dev] [PATCH v3 16/30] ixgbe/base: add new phy definitions

2016-06-15 Thread Beilei Xing
It adds new phy definitions.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_phy.c  |  16 +-
 drivers/net/ixgbe/base/ixgbe_type.h |  14 +-
 drivers/net/ixgbe/base/ixgbe_x550.c | 303 ++--
 drivers/net/ixgbe/base/ixgbe_x550.h |  43 +
 4 files changed, 355 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_phy.c 
b/drivers/net/ixgbe/base/ixgbe_phy.c
index 6ed685e..ed1b14f 100644
--- a/drivers/net/ixgbe/base/ixgbe_phy.c
+++ b/drivers/net/ixgbe/base/ixgbe_phy.c
@@ -454,6 +454,9 @@ enum ixgbe_phy_type ixgbe_get_phy_type_from_id(u32 phy_id)
case X557_PHY_ID:
phy_type = ixgbe_phy_x550em_ext_t;
break;
+   case IXGBE_M88E1500_E_PHY_ID:
+   phy_type = ixgbe_phy_m88;
+   break;
default:
phy_type = ixgbe_phy_unknown;
break;
@@ -615,13 +618,12 @@ s32 ixgbe_read_phy_reg_generic(struct ixgbe_hw *hw, u32 
reg_addr,

DEBUGFUNC("ixgbe_read_phy_reg_generic");

-   if (hw->mac.ops.acquire_swfw_sync(hw, gssr) == IXGBE_SUCCESS) {
-   status = ixgbe_read_phy_reg_mdi(hw, reg_addr, device_type,
-   phy_data);
-   hw->mac.ops.release_swfw_sync(hw, gssr);
-   } else {
-   status = IXGBE_ERR_SWFW_SYNC;
-   }
+   if (hw->mac.ops.acquire_swfw_sync(hw, gssr))
+   return IXGBE_ERR_SWFW_SYNC;
+
+   status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
+
+   hw->mac.ops.release_swfw_sync(hw, gssr);

return status;
 }
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index da1fe16..f1379be 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -1607,7 +1607,8 @@ struct ixgbe_dmac_config {
 #define ATH_PHY_ID 0x03429050

 /* PHY Types */
-#define IXGBE_M88E1145_E_PHY_ID0x01410CD0
+#define IXGBE_M88E1500_E_PHY_ID0x01410DD0
+#define IXGBE_M88E1543_E_PHY_ID0x01410EA0

 /* Special PHY Init Routine */
 #define IXGBE_PHY_INIT_OFFSET_NL   0x002B
@@ -3250,6 +3251,7 @@ typedef u32 ixgbe_autoneg_advertised;
 /* Link speed */
 typedef u32 ixgbe_link_speed;
 #define IXGBE_LINK_SPEED_UNKNOWN   0
+#define IXGBE_LINK_SPEED_10_FULL   0x0004
 #define IXGBE_LINK_SPEED_100_FULL  0x0008
 #define IXGBE_LINK_SPEED_1GB_FULL  0x0020
 #define IXGBE_LINK_SPEED_2_5GB_FULL0x0400
@@ -3574,6 +3576,14 @@ enum ixgbe_fc_mode {
ixgbe_fc_default
 };

+/* Master/slave control */
+enum ixgbe_ms_type {
+   ixgbe_ms_hw_default = 0,
+   ixgbe_ms_force_master,
+   ixgbe_ms_force_slave,
+   ixgbe_ms_auto
+};
+
 /* Smart Speed Settings */
 #define IXGBE_SMARTSPEED_MAX_RETRIES   3
 enum ixgbe_smart_speed {
@@ -3949,6 +3959,8 @@ struct ixgbe_phy_info {
bool reset_disable;
ixgbe_autoneg_advertised autoneg_advertised;
ixgbe_link_speed speeds_supported;
+   enum ixgbe_ms_type ms_type;
+   enum ixgbe_ms_type original_ms_type;
enum ixgbe_smart_speed smart_speed;
bool smart_speed_active;
bool multispeed_fiber;
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 993ef16..a4b444b 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -329,6 +329,100 @@ STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
 }

 /**
+ * ixgbe_read_phy_reg_mdi_22 - Read from a clause 22 PHY register without lock
+ * @hw: pointer to hardware structure
+ * @reg_addr: 32 bit address of PHY register to read
+ * @dev_type: always unused
+ * @phy_data: Pointer to read data from PHY register
+ */
+static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
+u32 dev_type, u16 *phy_data)
+{
+   u32 i, data, command;
+   UNREFERENCED_1PARAMETER(dev_type);
+
+   /* Setup and write the read command */
+   command = (reg_addr << IXGBE_MSCA_NP_ADDR_SHIFT)  |
+   (reg_addr << IXGBE_MSCA_DEV_TYPE_SHIFT) |
+   (hw->phy.addr << IXGBE_MSCA_PHY_ADDR_SHIFT) |
+   IXGBE_MSCA_OLD_PROTOCOL | IXGBE_MSCA_READ |
+   IXGBE_MSCA_MDI_COMMAND;
+
+   IXGBE_WRITE_REG(hw, IXGBE_MSCA, command);
+
+   /* Check every 10 usec to see if the access completed.
+* The MDI Command bit will clear when the operation is
+* complete
+*/
+   for (i = 0; i < IXGBE_MDIO_COMMAND_TIMEOUT; i++) {
+   usec_delay(10);
+
+   command = IXGBE_READ_REG(hw, IXGBE_MSCA);
+   if (!(command & IXGBE_MSCA_MDI_COMMAND))
+   break;
+   }
+
+   if (command & IXGBE_MSCA_MDI_COMMAND) {
+   ERROR_REPORT1(IXGBE_ERROR_POLLING,
+ "PHY read command did not complete.\n");
+   return IXGBE_ERR_PHY;
+  

[dpdk-dev] [PATCH v3 12/30] ixgbe/base: fix error path to release lock

2016-06-15 Thread Beilei Xing
When there is an error getting the PHY token, the error path
fails to release the locks that it has taken. Release those
locks in that failure case.

Fixes: 86b8fb293fdf ("ixgbe/base: add sw-firmware sync for resource sharing on 
X550em_a")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 0bb3436..e91546c 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -3530,17 +3530,22 @@ static s32 ixgbe_acquire_swfw_sync_X550a(struct 
ixgbe_hw *hw, u32 mask)
DEBUGFUNC("ixgbe_acquire_swfw_sync_X550a");

while (--retries) {
+   status = IXGBE_SUCCESS;
if (hmask)
status = ixgbe_acquire_swfw_sync_X540(hw, hmask);
if (status)
-   break;
+   return status;
if (!(mask & IXGBE_GSSR_TOKEN_SM))
-   break;
+   return IXGBE_SUCCESS;
+
status = ixgbe_get_phy_token(hw);
-   if (status != IXGBE_ERR_TOKEN_RETRY)
-   break;
+   if (status == IXGBE_SUCCESS)
+   return IXGBE_SUCCESS;
+
if (hmask)
ixgbe_release_swfw_sync_X540(hw, hmask);
+   if (status != IXGBE_ERR_TOKEN_RETRY)
+   return status;
msec_delay(FW_PHY_TOKEN_DELAY);
}

-- 
2.5.0



[dpdk-dev] [PATCH v3 18/30] ixgbe/base: add function to reset swfw semaphore

2016-06-15 Thread Beilei Xing
For X540 and forward it is possible if a system reset occur at the
right time to leave the SWFW semaphore high. This new function will
attempt to grab and release the semaphore. If the grab times out it
will still release the semaphore placing it in a known good state.
The idea is to call this when you know no one should be holding the
semaphore (i.e. probe time)

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c| 14 ++
 drivers/net/ixgbe/base/ixgbe_api.h|  1 +
 drivers/net/ixgbe/base/ixgbe_common.c |  1 +
 drivers/net/ixgbe/base/ixgbe_type.h   |  1 +
 drivers/net/ixgbe/base/ixgbe_x540.c   | 20 
 drivers/net/ixgbe/base/ixgbe_x540.h   |  1 +
 6 files changed, 38 insertions(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index 19e52c9..e117b86 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1639,6 +1639,20 @@ void ixgbe_release_swfw_semaphore(struct ixgbe_hw *hw, 
u32 mask)
hw->mac.ops.release_swfw_sync(hw, mask);
 }

+/**
+ *  ixgbe_init_swfw_semaphore - Clean up SWFW semaphore
+ *  @hw: pointer to hardware structure
+ *
+ *  Attempts to acquire the SWFW semaphore through SW_FW_SYNC register.
+ *  Regardless of whether is succeeds or not it then release the semaphore.
+ *  This is function is called to recover from catastrophic failures that
+ *  may have left the semaphore locked.
+ **/
+void ixgbe_init_swfw_semaphore(struct ixgbe_hw *hw)
+{
+   if (hw->mac.ops.init_swfw_sync)
+   hw->mac.ops.init_swfw_sync(hw);
+}

 void ixgbe_disable_rx(struct ixgbe_hw *hw)
 {
diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index ae26a6a..f5970a8 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -191,6 +191,7 @@ s32 ixgbe_set_san_mac_addr(struct ixgbe_hw *hw, u8 
*san_mac_addr);
 s32 ixgbe_get_device_caps(struct ixgbe_hw *hw, u16 *device_caps);
 s32 ixgbe_acquire_swfw_semaphore(struct ixgbe_hw *hw, u32 mask);
 void ixgbe_release_swfw_semaphore(struct ixgbe_hw *hw, u32 mask);
+void ixgbe_init_swfw_semaphore(struct ixgbe_hw *hw);
 s32 ixgbe_get_wwn_prefix(struct ixgbe_hw *hw, u16 *wwnn_prefix,
 u16 *wwpn_prefix);
 s32 ixgbe_get_fcoe_boot_status(struct ixgbe_hw *hw, u16 *bs);
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index d211303..0a74714 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4390,6 +4390,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 
*buffer,
DEBUGOUT1("Buffer length failure buffersize=%d.\n", length);
return IXGBE_ERR_HOST_INTERFACE_COMMAND;
}
+
/* Set bit 9 of FWSTS clearing FW reset indication */
fwsts = IXGBE_READ_REG(hw, IXGBE_FWSTS);
IXGBE_WRITE_REG(hw, IXGBE_FWSTS, fwsts | IXGBE_FWSTS_FWRI);
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 6a837f1..f40580d 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3785,6 +3785,7 @@ struct ixgbe_mac_operations {
s32 (*enable_sec_rx_path)(struct ixgbe_hw *);
s32 (*acquire_swfw_sync)(struct ixgbe_hw *, u32);
void (*release_swfw_sync)(struct ixgbe_hw *, u32);
+   void (*init_swfw_sync)(struct ixgbe_hw *);
s32 (*prot_autoc_read)(struct ixgbe_hw *, bool *, u32 *);
s32 (*prot_autoc_write)(struct ixgbe_hw *, u32, bool);

diff --git a/drivers/net/ixgbe/base/ixgbe_x540.c 
b/drivers/net/ixgbe/base/ixgbe_x540.c
index 0678913..31dead0 100644
--- a/drivers/net/ixgbe/base/ixgbe_x540.c
+++ b/drivers/net/ixgbe/base/ixgbe_x540.c
@@ -99,6 +99,7 @@ s32 ixgbe_init_ops_X540(struct ixgbe_hw *hw)
mac->ops.get_fcoe_boot_status = ixgbe_get_fcoe_boot_status_generic;
mac->ops.acquire_swfw_sync = ixgbe_acquire_swfw_sync_X540;
mac->ops.release_swfw_sync = ixgbe_release_swfw_sync_X540;
+   mac->ops.init_swfw_sync = ixgbe_init_swfw_sync_X540;
mac->ops.disable_sec_rx_path = ixgbe_disable_sec_rx_path_generic;
mac->ops.enable_sec_rx_path = ixgbe_enable_sec_rx_path_generic;

@@ -946,6 +947,25 @@ STATIC void ixgbe_release_swfw_sync_semaphore(struct 
ixgbe_hw *hw)
 }

 /**
+ *  ixgbe_init_swfw_sync_X540 - Release hardware semaphore
+ *  @hw: pointer to hardware structure
+ *
+ *  This function reset hardware semaphore bits for a semaphore that may
+ *  have be left locked due to a catastrophic failure.
+ **/
+void ixgbe_init_swfw_sync_X540(struct ixgbe_hw *hw)
+{
+   /* First try to grab the semaphore but we don't need to bother
+* looking to see whether we got the lock or  not since we do
+* the same thing regardless of whether we got the lock or not.
+* We got the lock - we release it.
+* We timeout trying to get the lock - we force 

[dpdk-dev] [PATCH v3 19/30] ixgbe/base: fix possible race issue

2016-06-15 Thread Beilei Xing
This patch fixes possible race issue between ports when issuing host
interface command by acquiring/releasing the management host interface
semaphore in ixgbe_host_interface_command.

Fixes: 36f43e8679ae ("ixgbe/base: refactor manageability block communication")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 40 ---
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 0a74714..0a708cf 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4373,8 +4373,9 @@ u8 ixgbe_calculate_checksum(u8 *buffer, u32 length)
  *   So we will leave this up to the caller to read back the data
  *   in these cases.
  *
- *  Communicates with the manageability block.  On success return IXGBE_SUCCESS
- *  else return IXGBE_ERR_HOST_INTERFACE_COMMAND.
+ *  Communicates with the manageability block. On success return IXGBE_SUCCESS
+ *  else returns semaphore error when encountering an error acquiring
+ *  semaphore or IXGBE_ERR_HOST_INTERFACE_COMMAND when command fails.
  **/
 s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 *buffer,
 u32 length, u32 timeout, bool return_data)
@@ -4383,6 +4384,7 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, u32 
*buffer,
u32 hdr_size = sizeof(struct ixgbe_hic_hdr);
u16 buf_len;
u16 dword_len;
+   s32 status;

DEBUGFUNC("ixgbe_host_interface_command");

@@ -4390,6 +4392,11 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
DEBUGOUT1("Buffer length failure buffersize=%d.\n", length);
return IXGBE_ERR_HOST_INTERFACE_COMMAND;
}
+   /* Take management host interface semaphore */
+   status = hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM);
+
+   if (status)
+   return status;

/* Set bit 9 of FWSTS clearing FW reset indication */
fwsts = IXGBE_READ_REG(hw, IXGBE_FWSTS);
@@ -4399,13 +4406,15 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
hicr = IXGBE_READ_REG(hw, IXGBE_HICR);
if ((hicr & IXGBE_HICR_EN) == 0) {
DEBUGOUT("IXGBE_HOST_EN bit disabled.\n");
-   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   status = IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   goto rel_out;
}

/* Calculate length in DWORDs. We must be DWORD aligned */
if ((length % (sizeof(u32))) != 0) {
DEBUGOUT("Buffer length failure, not aligned to dword");
-   return IXGBE_ERR_INVALID_ARGUMENT;
+   status = IXGBE_ERR_INVALID_ARGUMENT;
+   goto rel_out;
}

dword_len = length >> 2;
@@ -4432,11 +4441,12 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
!(IXGBE_READ_REG(hw, IXGBE_HICR) & IXGBE_HICR_SV)) {
ERROR_REPORT1(IXGBE_ERROR_CAUTION,
 "Command has failed with no status valid.\n");
-   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   status = IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   goto rel_out;
}

if (!return_data)
-   return 0;
+   goto rel_out;

/* Calculate length in DWORDs */
dword_len = hdr_size >> 2;
@@ -4450,11 +4460,12 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
/* If there is any thing in data position pull it in */
buf_len = ((struct ixgbe_hic_hdr *)buffer)->buf_len;
if (buf_len == 0)
-   return 0;
+   goto rel_out;

if (length < buf_len + hdr_size) {
DEBUGOUT("Buffer not large enough for reply message.\n");
-   return IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   status = IXGBE_ERR_HOST_INTERFACE_COMMAND;
+   goto rel_out;
}

/* Calculate length in DWORDs, add 3 for odd lengths */
@@ -4466,7 +4477,10 @@ s32 ixgbe_host_interface_command(struct ixgbe_hw *hw, 
u32 *buffer,
IXGBE_LE32_TO_CPUS([bi]);
}

-   return 0;
+rel_out:
+   hw->mac.ops.release_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM);
+
+   return status;
 }

 /**
@@ -4491,12 +4505,6 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 
maj, u8 min,

DEBUGFUNC("ixgbe_set_fw_drv_ver_generic");

-   if (hw->mac.ops.acquire_swfw_sync(hw, IXGBE_GSSR_SW_MNG_SM)
-   != IXGBE_SUCCESS) {
-   ret_val = IXGBE_ERR_SWFW_SYNC;
-   goto out;
-   }
-
fw_cmd.hdr.cmd = FW_CEM_CMD_DRIVER_INFO;
fw_cmd.hdr.buf_len = FW_CEM_CMD_DRIVER_INFO_LEN;
fw_cmd.hdr.cmd_or_resp.cmd_resv = FW_CEM_CMD_RESERVED;
@@ -4528,8 +4536,6 @@ s32 ixgbe_set_fw_drv_ver_generic(struct ixgbe_hw *hw, u8 
maj, u8 min,
break;
}

-  

[dpdk-dev] [PATCH v3 17/30] ixgbe/base: change device IDs

2016-06-15 Thread Beilei Xing
There're two device IDs changed from 15C6/15C7 to 15E4/15E5 cause
PHY info changes. Make the change and use 15C6/15C7 for the backplane
SGMII. Clean up some discovery kludges from the previous shared ID,
and also add 15C6/15C7 to ixgbe_set_mdio_speed just for paranoia
to control MDIO speed even though nothing should be attached.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c  |  2 ++
 drivers/net/ixgbe/base/ixgbe_type.h |  7 ---
 drivers/net/ixgbe/base/ixgbe_x550.c | 17 -
 lib/librte_eal/common/include/rte_pci_dev_ids.h | 12 
 4 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index cf1e516..19e52c9 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -209,6 +209,8 @@ s32 ixgbe_set_mac_type(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_A_KR:
case IXGBE_DEV_ID_X550EM_A_KR_L:
case IXGBE_DEV_ID_X550EM_A_SFP_N:
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
case IXGBE_DEV_ID_X550EM_A_10G_T:
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index f1379be..6a837f1 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -133,12 +133,14 @@ POSSIBILITY OF SUCH DAMAGE.
 #define IXGBE_DEV_ID_X550EM_A_KR   0x15C2
 #define IXGBE_DEV_ID_X550EM_A_KR_L 0x15C3
 #define IXGBE_DEV_ID_X550EM_A_SFP_N0x15C4
-#define IXGBE_DEV_ID_X550EM_A_1G_T 0x15C6
-#define IXGBE_DEV_ID_X550EM_A_1G_T_L   0x15C7
+#define IXGBE_DEV_ID_X550EM_A_SGMII0x15C6
+#define IXGBE_DEV_ID_X550EM_A_SGMII_L  0x15C7
 #define IXGBE_DEV_ID_X550EM_A_10G_T0x15C8
 #define IXGBE_DEV_ID_X550EM_A_QSFP 0x15CA
 #define IXGBE_DEV_ID_X550EM_A_QSFP_N   0x15CC
 #define IXGBE_DEV_ID_X550EM_A_SFP  0x15CE
+#define IXGBE_DEV_ID_X550EM_A_1G_T 0x15E4
+#define IXGBE_DEV_ID_X550EM_A_1G_T_L   0x15E5
 #define IXGBE_DEV_ID_X550EM_X_KX4  0x15AA
 #define IXGBE_DEV_ID_X550EM_X_KR   0x15AB
 #define IXGBE_DEV_ID_X550EM_X_SFP  0x15AC
@@ -3562,7 +3564,6 @@ enum ixgbe_media_type {
ixgbe_media_type_fiber_lco,
ixgbe_media_type_copper,
ixgbe_media_type_backplane,
-   ixgbe_media_type_sgmii,
ixgbe_media_type_cx4,
ixgbe_media_type_virtual
 };
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index a4b444b..7aad0bd 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1487,10 +1487,15 @@ enum ixgbe_media_type 
ixgbe_get_media_type_X550em(struct ixgbe_hw *hw)
case IXGBE_DEV_ID_X550EM_A_10G_T:
media_type = ixgbe_media_type_copper;
break;
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
+   media_type = ixgbe_media_type_backplane;
+   hw->phy.type = ixgbe_phy_sgmii;
+   break;
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
-   media_type = ixgbe_media_type_sgmii;
-   hw->phy.type = ixgbe_phy_sgmii;
+   media_type = ixgbe_media_type_copper;
+   hw->phy.type = ixgbe_phy_m88;
break;
default:
media_type = ixgbe_media_type_unknown;
@@ -1667,9 +1672,9 @@ void ixgbe_init_mac_link_ops_X550em(struct ixgbe_hw *hw)
mac->ops.check_link = ixgbe_check_link_t_X550em;
break;
case ixgbe_media_type_backplane:
-   break;
-   case ixgbe_media_type_sgmii:
-   mac->ops.setup_link = ixgbe_setup_sgmii;
+   if (hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII ||
+   hw->device_id == IXGBE_DEV_ID_X550EM_A_SGMII_L)
+   mac->ops.setup_link = ixgbe_setup_sgmii;
break;
default:
break;
@@ -2229,6 +2234,8 @@ static void ixgbe_set_mdio_speed(struct ixgbe_hw *hw)

switch (hw->device_id) {
case IXGBE_DEV_ID_X550EM_X_10G_T:
+   case IXGBE_DEV_ID_X550EM_A_SGMII:
+   case IXGBE_DEV_ID_X550EM_A_SGMII_L:
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
case IXGBE_DEV_ID_X550EM_A_10G_T:
diff --git a/lib/librte_eal/common/include/rte_pci_dev_ids.h 
b/lib/librte_eal/common/include/rte_pci_dev_ids.h
index cf7b548..63648c7 100644
--- a/lib/librte_eal/common/include/rte_pci_dev_ids.h
+++ b/lib/librte_eal/common/include/rte_pci_dev_ids.h
@@ -446,12 +446,14 @@ RTE_PCI_DEV_ID_DECL_IGB(PCI_VENDOR_ID_INTEL, 
E1000_DEV_ID_DH89XXCC_SFP)
 #define IXGBE_DEV_ID_X550EM_A_KR

[dpdk-dev] [PATCH v3 20/30] ixgbe/base: fix register access error

2016-06-15 Thread Beilei Xing
This patch corrects the FLA/GSCL/GSCN access offset value according
to the datasheet.

Fixes: 0790adeb5675 ("ixgbe/base: support X550em_a device")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h | 42 -
 1 file changed, 41 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index f40580d..ec1f4e0 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -196,7 +196,7 @@ POSSIBILITY OF SUCH DAMAGE.
 #define IXGBE_FLA_X540 IXGBE_FLA
 #define IXGBE_FLA_X550 IXGBE_FLA
 #define IXGBE_FLA_X550EM_x IXGBE_FLA
-#define IXGBE_FLA_X550EM_a 0x15F6C
+#define IXGBE_FLA_X550EM_a 0x15F68
 #define IXGBE_FLA_BY_MAC(_hw)  IXGBE_BY_MAC((_hw), FLA)

 #define IXGBE_EEMNGCTL 0x10110
@@ -1080,16 +1080,40 @@ struct ixgbe_dmac_config {
 #define IXGBE_PCIEPIPEDAT  0x11008
 #define IXGBE_GSCL_1   0x11010
 #define IXGBE_GSCL_2   0x11014
+#define IXGBE_GSCL_1_X540  IXGBE_GSCL_1
+#define IXGBE_GSCL_2_X540  IXGBE_GSCL_2
 #define IXGBE_GSCL_3   0x11018
 #define IXGBE_GSCL_4   0x1101C
 #define IXGBE_GSCN_0   0x11020
 #define IXGBE_GSCN_1   0x11024
 #define IXGBE_GSCN_2   0x11028
 #define IXGBE_GSCN_3   0x1102C
+#define IXGBE_GSCN_0_X540  IXGBE_GSCN_0
+#define IXGBE_GSCN_1_X540  IXGBE_GSCN_1
+#define IXGBE_GSCN_2_X540  IXGBE_GSCN_2
+#define IXGBE_GSCN_3_X540  IXGBE_GSCN_3
 #define IXGBE_FACTPS   0x10150
 #define IXGBE_FACTPS_X540  IXGBE_FACTPS
+#define IXGBE_GSCL_1_X550  0x11800
+#define IXGBE_GSCL_2_X550  0x11804
+#define IXGBE_GSCL_1_X550EM_x  IXGBE_GSCL_1_X550
+#define IXGBE_GSCL_2_X550EM_x  IXGBE_GSCL_2_X550
+#define IXGBE_GSCN_0_X550  0x11820
+#define IXGBE_GSCN_1_X550  0x11824
+#define IXGBE_GSCN_2_X550  0x11828
+#define IXGBE_GSCN_3_X550  0x1182C
+#define IXGBE_GSCN_0_X550EM_x  IXGBE_GSCN_0_X550
+#define IXGBE_GSCN_1_X550EM_x  IXGBE_GSCN_1_X550
+#define IXGBE_GSCN_2_X550EM_x  IXGBE_GSCN_2_X550
+#define IXGBE_GSCN_3_X550EM_x  IXGBE_GSCN_3_X550
 #define IXGBE_FACTPS_X550  IXGBE_FACTPS
 #define IXGBE_FACTPS_X550EM_x  IXGBE_FACTPS
+#define IXGBE_GSCL_1_X550EM_a  IXGBE_GSCL_1_X550
+#define IXGBE_GSCL_2_X550EM_a  IXGBE_GSCL_2_X550
+#define IXGBE_GSCN_0_X550EM_a  IXGBE_GSCN_0_X550
+#define IXGBE_GSCN_1_X550EM_a  IXGBE_GSCN_1_X550
+#define IXGBE_GSCN_2_X550EM_a  IXGBE_GSCN_2_X550
+#define IXGBE_GSCN_3_X550EM_a  IXGBE_GSCN_3_X550
 #define IXGBE_FACTPS_X550EM_a  0x15FEC
 #define IXGBE_FACTPS_BY_MAC(_hw)   IXGBE_BY_MAC((_hw), FACTPS)

@@ -1126,6 +1150,10 @@ struct ixgbe_dmac_config {
 #define IXGBE_GSCL_6_82599 0x11034
 #define IXGBE_GSCL_7_82599 0x11038
 #define IXGBE_GSCL_8_82599 0x1103C
+#define IXGBE_GSCL_5_X540  IXGBE_GSCL_5_82599
+#define IXGBE_GSCL_6_X540  IXGBE_GSCL_6_82599
+#define IXGBE_GSCL_7_X540  IXGBE_GSCL_7_82599
+#define IXGBE_GSCL_8_X540  IXGBE_GSCL_8_82599
 #define IXGBE_PHYADR_82599 0x11040
 #define IXGBE_PHYDAT_82599 0x11044
 #define IXGBE_PHYCTL_82599 0x11048
@@ -1136,10 +1164,22 @@ struct ixgbe_dmac_config {
 #define IXGBE_CIAD_82599   IXGBE_CIAD
 #define IXGBE_CIAA_X540IXGBE_CIAA
 #define IXGBE_CIAD_X540IXGBE_CIAD
+#define IXGBE_GSCL_5_X550  0x11810
+#define IXGBE_GSCL_6_X550  0x11814
+#define IXGBE_GSCL_7_X550  0x11818
+#define IXGBE_GSCL_8_X550  0x1181C
+#define IXGBE_GSCL_5_X550EM_x  IXGBE_GSCL_5_X550
+#define IXGBE_GSCL_6_X550EM_x  IXGBE_GSCL_6_X550
+#define IXGBE_GSCL_7_X550EM_x  IXGBE_GSCL_7_X550
+#define IXGBE_GSCL_8_X550EM_x  IXGBE_GSCL_8_X550
 #define IXGBE_CIAA_X5500x11508
 #define IXGBE_CIAD_X5500x11510
 #define IXGBE_CIAA_X550EM_xIXGBE_CIAA_X550
 #define IXGBE_CIAD_X550EM_xIXGBE_CIAD_X550
+#define IXGBE_GSCL_5_X550EM_a  IXGBE_GSCL_5_X550
+#define IXGBE_GSCL_6_X550EM_a  IXGBE_GSCL_6_X550
+#define IXGBE_GSCL_7_X550EM_a  IXGBE_GSCL_7_X550
+#define IXGBE_GSCL_8_X550EM_a  IXGBE_GSCL_8_X550
 #define IXGBE_CIAA_X550EM_aIXGBE_CIAA_X550
 #define IXGBE_CIAD_X550EM_aIXGBE_CIAD_X550
 #define IXGBE_CIAA_BY_MAC(_hw) IXGBE_BY_MAC((_hw), CIAA)
-- 
2.5.0



[dpdk-dev] [PATCH v3 21/30] ixgbe/base: limit PHY token accessing to MDIO only

2016-06-15 Thread Beilei Xing
This patch limits getting and putting the PHY Token to PHY MDIO
access only by adding ixgbe_read_phy_reg_x550a and
ixgbe_write_phy_reg_x550a. The PHY Token is only needed to
synchronize access to the MDIO shared between the two MAC instance.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 65 +++--
 drivers/net/ixgbe/base/ixgbe_x550.h |  4 +++
 2 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 7aad0bd..80f59fb 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -469,7 +469,8 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
 {
switch (hw->device_id) {
case IXGBE_DEV_ID_X550EM_A_SFP:
-   hw->phy.phy_semaphore_mask = IXGBE_GSSR_TOKEN_SM;
+   hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
+   hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
if (hw->bus.lan_id)
hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
else
@@ -499,7 +500,8 @@ STATIC s32 ixgbe_identify_phy_x550em(struct ixgbe_hw *hw)
return ixgbe_identify_phy_generic(hw);
case IXGBE_DEV_ID_X550EM_A_1G_T:
case IXGBE_DEV_ID_X550EM_A_1G_T_L:
-   hw->phy.phy_semaphore_mask = IXGBE_GSSR_TOKEN_SM;
+   hw->phy.ops.read_reg = ixgbe_read_phy_reg_x550a;
+   hw->phy.ops.write_reg = ixgbe_write_phy_reg_x550a;
if (hw->bus.lan_id)
hw->phy.phy_semaphore_mask |= IXGBE_GSSR_PHY1_SM;
else
@@ -1245,6 +1247,8 @@ s32 ixgbe_put_phy_token(struct ixgbe_hw *hw)
return status;
if (token_cmd.hdr.cmd_or_resp.ret_status == FW_PHY_TOKEN_OK)
return IXGBE_SUCCESS;
+
+   DEBUGOUT("Put PHY Token host interface command failed");
return IXGBE_ERR_FW_RESP_INVALID;
 }

@@ -3870,6 +3874,63 @@ static void ixgbe_release_swfw_sync_X550a(struct 
ixgbe_hw *hw, u32 mask)
 }

 /**
+ *  ixgbe_read_phy_reg_x550a  - Reads specified PHY register
+ *  @hw: pointer to hardware structure
+ *  @reg_addr: 32 bit address of PHY register to read
+ *  @phy_data: Pointer to read data from PHY register
+ *
+ *  Reads a value from a specified PHY register using the SWFW lock and PHY
+ *  Token. The PHY Token is needed since the MDIO is shared between to MAC
+ *  instances.
+ **/
+s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
+u32 device_type, u16 *phy_data)
+{
+   s32 status;
+   u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
+
+   DEBUGFUNC("ixgbe_read_phy_reg_x550a");
+
+   if (hw->mac.ops.acquire_swfw_sync(hw, mask))
+   return IXGBE_ERR_SWFW_SYNC;
+
+   status = hw->phy.ops.read_reg_mdi(hw, reg_addr, device_type, phy_data);
+
+   hw->mac.ops.release_swfw_sync(hw, mask);
+
+   return status;
+}
+
+/**
+ *  ixgbe_write_phy_reg_x550a - Writes specified PHY register
+ *  @hw: pointer to hardware structure
+ *  @reg_addr: 32 bit PHY register to write
+ *  @device_type: 5 bit device type
+ *  @phy_data: Data to write to the PHY register
+ *
+ *  Writes a value to specified PHY register using the SWFW lock and PHY Token.
+ *  The PHY Token is needed since the MDIO is shared between to MAC instances.
+ **/
+s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
+ u32 device_type, u16 phy_data)
+{
+   s32 status;
+   u32 mask = hw->phy.phy_semaphore_mask | IXGBE_GSSR_TOKEN_SM;
+
+   DEBUGFUNC("ixgbe_write_phy_reg_x550a");
+
+   if (hw->mac.ops.acquire_swfw_sync(hw, mask) == IXGBE_SUCCESS) {
+   status = ixgbe_write_phy_reg_mdi(hw, reg_addr, device_type,
+phy_data);
+   hw->mac.ops.release_swfw_sync(hw, mask);
+   } else {
+   status = IXGBE_ERR_SWFW_SYNC;
+   }
+
+   return status;
+}
+
+/**
  * ixgbe_handle_lasi_ext_t_x550em - Handle external Base T PHY interrupt
  * @hw: pointer to hardware structure
  *
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.h 
b/drivers/net/ixgbe/base/ixgbe_x550.h
index a6ec3cb..b597b50 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.h
+++ b/drivers/net/ixgbe/base/ixgbe_x550.h
@@ -146,6 +146,10 @@ s32 ixgbe_setup_mac_link_sfp_x550em(struct ixgbe_hw *hw,
 s32 ixgbe_setup_mac_link_sfp_x550a(struct ixgbe_hw *hw,
   ixgbe_link_speed speed,
   bool autoneg_wait_to_complete);
+s32 ixgbe_read_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
+u32 device_type, u16 *phy_data);
+s32 ixgbe_write_phy_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
+ u32 device_type, u16 phy_data);
 s32 ixgbe_handle_lasi_ext_t_x550em(struct ixgbe_hw *hw);
 s32 

[dpdk-dev] [PATCH v3 22/30] ixgbe/base: simplify add/remove VLANs

2016-06-15 Thread Beilei Xing
This patch simplifies the adding and removing VLANs from
VFTA/VLVF/VLVFB registers. The logic to determine registers has
been simplified to (vid / 32) and (1 - vid / 32). Many conditional
paths and checks are no longer needed with this patch.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.c|  18 ++--
 drivers/net/ixgbe/base/ixgbe_api.h|   2 +-
 drivers/net/ixgbe/base/ixgbe_common.c | 188 ++
 drivers/net/ixgbe/base/ixgbe_common.h |   2 +-
 drivers/net/ixgbe/base/ixgbe_type.h   |   2 +-
 5 files changed, 91 insertions(+), 121 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index e117b86..90deaf1 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1080,8 +1080,8 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw)
  *  ixgbe_set_vfta - Set VLAN filter table
  *  @hw: pointer to hardware structure
  *  @vlan: VLAN id to write to VLAN filter
- *  @vind: VMDq output index that maps queue to VLAN id in VFTA
- *  @vlan_on: boolean flag to turn on/off VLAN in VFTA
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
@@ -1095,18 +1095,20 @@ s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 
vind, bool vlan_on)
  *  ixgbe_set_vlvf - Set VLAN Pool Filter
  *  @hw: pointer to hardware structure
  *  @vlan: VLAN id to write to VLAN filter
- *  @vind: VMDq output index that maps queue to VLAN id in VFVFB
- *  @vlan_on: boolean flag to turn on/off VLAN in VFVF
- *  @vfta_changed: pointer to boolean flag which indicates whether VFTA
- * should be changed
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN in VLVF
+ *  @vfta_delta: pointer to the difference between the current value of VFTA
+ *   and the desired value
+ *  @vfta: the desired value of the VFTA
  *
  *  Turn on/off specified bit in VLVF table.
  **/
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
-   bool *vfta_changed)
+  u32 *vfta_delta, u32 vfta)
 {
return ixgbe_call_func(hw, hw->mac.ops.set_vlvf, (hw, vlan, vind,
-  vlan_on, vfta_changed), IXGBE_NOT_IMPLEMENTED);
+  vlan_on, vfta_delta, vfta),
+  IXGBE_NOT_IMPLEMENTED);
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index f5970a8..9431d14 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -126,7 +126,7 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw);
 s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan,
   u32 vind, bool vlan_on);
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind,
-  bool vlan_on, bool *vfta_changed);
+  bool vlan_on, u32 *vfta_delta, u32 vfta);
 s32 ixgbe_fc_enable(struct ixgbe_hw *hw);
 s32 ixgbe_setup_fc(struct ixgbe_hw *hw);
 s32 ixgbe_set_fw_drv_ver(struct ixgbe_hw *hw, u8 maj, u8 min, u8 build,
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 0a708cf..4551a2a 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -3853,24 +3853,20 @@ s32 ixgbe_find_vlvf_slot(struct ixgbe_hw *hw, u32 vlan)
  *  ixgbe_set_vfta_generic - Set VLAN filter table
  *  @hw: pointer to hardware structure
  *  @vlan: VLAN id to write to VLAN filter
- *  @vind: VMDq output index that maps queue to VLAN id in VFVFB
- *  @vlan_on: boolean flag to turn on/off VLAN in VFVF
+ *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
+ *  @vlan_on: boolean flag to turn on/off VLAN
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
 s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 vlan, u32 vind,
   bool vlan_on)
 {
-   s32 regindex;
-   u32 bitindex;
-   u32 vfta;
-   u32 targetbit;
-   s32 ret_val = IXGBE_SUCCESS;
-   bool vfta_changed = false;
+   u32 regidx, vfta_delta, vfta;
+   s32 ret_val;

DEBUGFUNC("ixgbe_set_vfta_generic");

-   if (vlan > 4095)
+   if (vlan > 4095 || vind > 63)
return IXGBE_ERR_PARAM;

/*
@@ -3885,33 +3881,28 @@ s32 ixgbe_set_vfta_generic(struct ixgbe_hw *hw, u32 
vlan, u32 vind,
 *bits[11-5]: which register
 *bits[4-0]:  which bit in the register
 */
-   regindex = (vlan >> 5) & 0x7F;
-   bitindex = vlan & 0x1F;
-   targetbit = (1 << bitindex);
-   vfta = IXGBE_READ_REG(hw, IXGBE_VFTA(regindex));
-
-   if (vlan_on) {
-   if (!(vfta & targetbit)) {
-   vfta |= targetbit;
-   vfta_changed = true;
-   }
-   } else {

[dpdk-dev] [PATCH v3 23/30] ixgbe/base: add bypassing VLVF

2016-06-15 Thread Beilei Xing
This patch adds support for the VLVF to be bypassed when adding or
removing a VFTA entry.  The PF can utilize the default pool while
preserving the VLVF for the VFs use.
Meanwhile, update corresponding VF ops and drivers where corresponding
ops is invoked.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_82598.c  |  5 ++-
 drivers/net/ixgbe/base/ixgbe_82598.h  |  3 +-
 drivers/net/ixgbe/base/ixgbe_api.c| 11 --
 drivers/net/ixgbe/base/ixgbe_api.h|  5 ++-
 drivers/net/ixgbe/base/ixgbe_common.c | 71 +++
 drivers/net/ixgbe/base/ixgbe_common.h |  7 ++--
 drivers/net/ixgbe/base/ixgbe_type.h   |  5 ++-
 drivers/net/ixgbe/base/ixgbe_vf.c |  6 ++-
 drivers/net/ixgbe/base/ixgbe_vf.h |  3 +-
 drivers/net/ixgbe/ixgbe_ethdev.c  | 11 --
 drivers/net/ixgbe/ixgbe_pf.c  |  2 +-
 11 files changed, 76 insertions(+), 53 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_82598.c 
b/drivers/net/ixgbe/base/ixgbe_82598.c
index 9e65fff..db80880 100644
--- a/drivers/net/ixgbe/base/ixgbe_82598.c
+++ b/drivers/net/ixgbe/base/ixgbe_82598.c
@@ -995,17 +995,20 @@ STATIC s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, 
u32 rar, u32 vmdq)
  *  @vlan: VLAN id to write to VLAN filter
  *  @vind: VMDq output index that maps queue to VLAN id in VFTA
  *  @vlan_on: boolean flag to turn on/off VLAN in VFTA
+ *  @bypass_vlvf: boolean flag - unused
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
 s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind,
-bool vlan_on)
+bool vlan_on, bool bypass_vlvf)
 {
u32 regindex;
u32 bitindex;
u32 bits;
u32 vftabyte;

+   UNREFERENCED_1PARAMETER(bypass_vlvf);
+
DEBUGFUNC("ixgbe_set_vfta_82598");

if (vlan > 4095)
diff --git a/drivers/net/ixgbe/base/ixgbe_82598.h 
b/drivers/net/ixgbe/base/ixgbe_82598.h
index 89dd11a..0326e70 100644
--- a/drivers/net/ixgbe/base/ixgbe_82598.h
+++ b/drivers/net/ixgbe/base/ixgbe_82598.h
@@ -39,7 +39,8 @@ s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw);
 s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw);
 void ixgbe_enable_relaxed_ordering_82598(struct ixgbe_hw *hw);
 s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq);
-s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool 
vlan_on);
+s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
+bool vlvf_bypass);
 s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val);
 s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val);
 s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
diff --git a/drivers/net/ixgbe/base/ixgbe_api.c 
b/drivers/net/ixgbe/base/ixgbe_api.c
index 90deaf1..1786867 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.c
+++ b/drivers/net/ixgbe/base/ixgbe_api.c
@@ -1082,13 +1082,15 @@ s32 ixgbe_clear_vfta(struct ixgbe_hw *hw)
  *  @vlan: VLAN id to write to VLAN filter
  *  @vind: VMDq output index that maps queue to VLAN id in VLVFB
  *  @vlan_on: boolean flag to turn on/off VLAN
+ *  @vlvf_bypass: boolean flag indicating updating the default pool is okay
  *
  *  Turn on/off specified VLAN in the VLAN filter table.
  **/
-s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on)
+s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
+  bool vlvf_bypass)
 {
return ixgbe_call_func(hw, hw->mac.ops.set_vfta, (hw, vlan, vind,
-  vlan_on), IXGBE_NOT_IMPLEMENTED);
+ vlan_on, vlvf_bypass), IXGBE_NOT_IMPLEMENTED);
 }

 /**
@@ -1100,14 +1102,15 @@ s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan, u32 
vind, bool vlan_on)
  *  @vfta_delta: pointer to the difference between the current value of VFTA
  *   and the desired value
  *  @vfta: the desired value of the VFTA
+ *  @vlvf_bypass: boolean flag indicating updating the default pool is okay
  *
  *  Turn on/off specified bit in VLVF table.
  **/
 s32 ixgbe_set_vlvf(struct ixgbe_hw *hw, u32 vlan, u32 vind, bool vlan_on,
-  u32 *vfta_delta, u32 vfta)
+  u32 *vfta_delta, u32 vfta, bool vlvf_bypass)
 {
return ixgbe_call_func(hw, hw->mac.ops.set_vlvf, (hw, vlan, vind,
-  vlan_on, vfta_delta, vfta),
+   vlan_on, vfta_delta, vfta, vlvf_bypass),
   IXGBE_NOT_IMPLEMENTED);
 }

diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index 9431d14..c126982 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -124,9 +124,10 @@ s32 ixgbe_enable_mc(struct ixgbe_hw *hw);
 s32 ixgbe_disable_mc(struct ixgbe_hw *hw);
 s32 ixgbe_clear_vfta(struct ixgbe_hw *hw);
 s32 ixgbe_set_vfta(struct ixgbe_hw *hw, u32 vlan,
-  u32 vind, bool 

[dpdk-dev] [PATCH v3 24/30] ixgbe/base: unify coding style

2016-06-15 Thread Beilei Xing
This patch changes static keyword to STATIC definition, which can be
redefined depending on the compiler used.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_x550.c | 38 ++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 80f59fb..1137179 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -39,8 +39,8 @@ POSSIBILITY OF SUCH DAMAGE.
 #include "ixgbe_phy.h"

 STATIC s32 ixgbe_setup_ixfi_x550em(struct ixgbe_hw *hw, ixgbe_link_speed 
*speed);
-static s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
-static void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
+STATIC s32 ixgbe_acquire_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);
+STATIC void ixgbe_release_swfw_sync_X550a(struct ixgbe_hw *, u32 mask);

 /**
  *  ixgbe_init_ops_X550 - Inits func ptrs and MAC type
@@ -335,7 +335,7 @@ STATIC void ixgbe_setup_mux_ctl(struct ixgbe_hw *hw)
  * @dev_type: always unused
  * @phy_data: Pointer to read data from PHY register
  */
-static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
+STATIC s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
 u32 dev_type, u16 *phy_data)
 {
u32 i, data, command;
@@ -383,7 +383,7 @@ static s32 ixgbe_read_phy_reg_mdi_22(struct ixgbe_hw *hw, 
u32 reg_addr,
  * @dev_type: always unused
  * @phy_data: Data to write to the PHY register
  */
-static s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
+STATIC s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, u32 reg_addr,
  u32 dev_type, u16 phy_data)
 {
u32 i, command;
@@ -428,7 +428,7 @@ static s32 ixgbe_write_phy_reg_mdi_22(struct ixgbe_hw *hw, 
u32 reg_addr,
  *
  * Returns error code
  */
-static s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_identify_phy_1g(struct ixgbe_hw *hw)
 {
u32 swfw_mask = hw->phy.phy_semaphore_mask;
u16 phy_id_high;
@@ -536,7 +536,7 @@ STATIC s32 ixgbe_write_phy_reg_x550em(struct ixgbe_hw *hw, 
u32 reg_addr,
  *
  * Returns an error code on error.
  **/
-static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
+STATIC s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw *hw, u8 addr,
   u16 reg, u16 *val)
 {
return ixgbe_read_i2c_combined_generic_int(hw, addr, reg, val, true);
@@ -551,7 +551,7 @@ static s32 ixgbe_read_i2c_combined_generic(struct ixgbe_hw 
*hw, u8 addr,
  *
  * Returns an error code on error.
  **/
-static s32
+STATIC s32
 ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw *hw, u8 addr,
 u16 reg, u16 *val)
 {
@@ -567,7 +567,7 @@ ixgbe_read_i2c_combined_generic_unlocked(struct ixgbe_hw 
*hw, u8 addr,
  *
  * Returns an error code on error.
  **/
-static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
+STATIC s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw *hw,
u8 addr, u16 reg, u16 val)
 {
return ixgbe_write_i2c_combined_generic_int(hw, addr, reg, val, true);
@@ -582,7 +582,7 @@ static s32 ixgbe_write_i2c_combined_generic(struct ixgbe_hw 
*hw,
  *
  * Returns an error code on error.
  **/
-static s32
+STATIC s32
 ixgbe_write_i2c_combined_generic_unlocked(struct ixgbe_hw *hw,
  u8 addr, u16 reg, u16 val)
 {
@@ -864,7 +864,7 @@ s32 ixgbe_init_eeprom_params_X550(struct ixgbe_hw *hw)
  * ixgbe_enable_eee_x550 - Enable EEE support
  * @hw: pointer to hardware structure
  */
-static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
 {
u16 autoneg_eee_reg;
u32 link_reg;
@@ -919,7 +919,7 @@ static s32 ixgbe_enable_eee_x550(struct ixgbe_hw *hw)
  * ixgbe_disable_eee_x550 - Disable EEE support
  * @hw: pointer to hardware structure
  */
-static s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_disable_eee_x550(struct ixgbe_hw *hw)
 {
u16 autoneg_eee_reg;
u32 link_reg;
@@ -1595,7 +1595,7 @@ s32 ixgbe_setup_sfp_modules_X550em(struct ixgbe_hw *hw)
  * ixgbe_setup_sgmii - Set up link for sgmii
  * @hw: pointer to hardware structure
  */
-static s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
+STATIC s32 ixgbe_setup_sgmii(struct ixgbe_hw *hw, ixgbe_link_speed speed,
 bool autoneg_wait_to_complete)
 {
struct ixgbe_mac_info *mac = >mac;
@@ -1960,7 +1960,7 @@ STATIC s32 ixgbe_setup_kr_speed_x550em(struct ixgbe_hw 
*hw,
  *
  * Must be called while holding the PHY semaphore and token
  */
-static s32 ixgbe_set_master_slave_mode(struct ixgbe_hw *hw)
+STATIC s32 ixgbe_set_master_slave_mode(struct ixgbe_hw *hw)
 {
u16 phy_data;
s32 rc;
@@ -2007,7 +2007,7 @@ 

[dpdk-dev] [PATCH v3 25/30] ixgbe/base: use u8 to replace u16 for a variable

2016-06-15 Thread Beilei Xing
Since PCIe standard defines maximum of 8 functions per device lan_id
is a value 0..7. Because of that, lan_id don't need to be u16.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 2 +-
 drivers/net/ixgbe/base/ixgbe_type.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 80ea3b9..6e54628 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -1034,7 +1034,7 @@ void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw)

reg = IXGBE_READ_REG(hw, IXGBE_STATUS);
bus->func = (reg & IXGBE_STATUS_LAN_ID) >> IXGBE_STATUS_LAN_ID_SHIFT;
-   bus->lan_id = bus->func;
+   bus->lan_id = (u8)bus->func;

/* check for a port swap */
reg = IXGBE_READ_REG(hw, IXGBE_FACTPS_BY_MAC(hw));
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 3bf0de0..d91c4ed 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3684,7 +3684,7 @@ struct ixgbe_bus_info {
enum ixgbe_bus_type type;

u16 func;
-   u16 lan_id;
+   u8 lan_id;
u16 instance_id;
 };

-- 
2.5.0



[dpdk-dev] [PATCH v3 26/30] ixgbe/base: fix endianness issues

2016-06-15 Thread Beilei Xing
This patch fixes endianness issues about host interface command.

Fixes: ad66a85dce9a ("ixgbe/base: new FW values")
Fixes: 0790adeb5675 ("ixgbe/base: support X550em_a device")

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_osdep.h |  1 +
 drivers/net/ixgbe/base/ixgbe_type.h  | 17 ++---
 drivers/net/ixgbe/base/ixgbe_x550.c  | 29 -
 3 files changed, 31 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_osdep.h 
b/drivers/net/ixgbe/base/ixgbe_osdep.h
index 40b0b51..31cc1be 100644
--- a/drivers/net/ixgbe/base/ixgbe_osdep.h
+++ b/drivers/net/ixgbe/base/ixgbe_osdep.h
@@ -96,6 +96,7 @@ enum {
 #define IXGBE_NTOHL(_i)rte_be_to_cpu_32(_i)
 #define IXGBE_NTOHS(_i)rte_be_to_cpu_16(_i)
 #define IXGBE_CPU_TO_LE32(_i)  rte_cpu_to_le_32(_i)
+#define IXGBE_LE32_TO_CPU(_i) rte_le_to_cpu_32(_i)
 #define IXGBE_LE32_TO_CPUS(_i) rte_le_to_cpu_32(_i)
 #define IXGBE_CPU_TO_BE16(_i)  rte_cpu_to_be_16(_i)
 #define IXGBE_CPU_TO_BE32(_i)  rte_cpu_to_be_32(_i)
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index d91c4ed..5d76c72 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3050,6 +3050,12 @@ enum ixgbe_fdir_pballoc_type {

 /* Host Interface Command Structures */

+#ifdef C99
+#pragma pack(push, 1)
+#else
+#pragma pack(1)
+#endif /* C99 */
+
 struct ixgbe_hic_hdr {
u8 cmd;
u8 buf_len;
@@ -3127,17 +3133,22 @@ struct ixgbe_hic_internal_phy_req {
struct ixgbe_hic_hdr hdr;
u8 port_number;
u8 command_type;
-   u16 address;
+   __be16 address;
u16 rsv1;
-   u32 write_data;
+   __le32 write_data;
u16 pad;
 };

 struct ixgbe_hic_internal_phy_resp {
struct ixgbe_hic_hdr hdr;
-   u32 read_data;
+   __le32 read_data;
 };

+#ifdef C99
+#pragma pack(pop)
+#else
+#pragma pack()
+#endif /* C99 */

 /* Transmit Descriptor - Legacy */
 struct ixgbe_legacy_tx_desc {
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 1137179..99023e9 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -1273,8 +1273,8 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
write_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
write_cmd.port_number = hw->bus.lan_id;
write_cmd.command_type = FW_INT_PHY_REQ_WRITE;
-   write_cmd.address = (u16)reg_addr;
-   write_cmd.write_data = data;
+   write_cmd.address = IXGBE_CPU_TO_BE16(reg_addr);
+   write_cmd.write_data = IXGBE_CPU_TO_LE32(data);

status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
  sizeof(write_cmd),
@@ -1294,24 +1294,27 @@ s32 ixgbe_write_iosf_sb_reg_x550a(struct ixgbe_hw *hw, 
u32 reg_addr,
 s32 ixgbe_read_iosf_sb_reg_x550a(struct ixgbe_hw *hw, u32 reg_addr,
 u32 device_type, u32 *data)
 {
-   struct ixgbe_hic_internal_phy_req read_cmd;
+   union {
+   struct ixgbe_hic_internal_phy_req cmd;
+   struct ixgbe_hic_internal_phy_resp rsp;
+   } hic;
s32 status;
UNREFERENCED_1PARAMETER(device_type);

-   memset(_cmd, 0, sizeof(read_cmd));
-   read_cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
-   read_cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
-   read_cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
-   read_cmd.port_number = hw->bus.lan_id;
-   read_cmd.command_type = FW_INT_PHY_REQ_READ;
-   read_cmd.address = (u16)reg_addr;
+   memset(, 0, sizeof(hic));
+   hic.cmd.hdr.cmd = FW_INT_PHY_REQ_CMD;
+   hic.cmd.hdr.buf_len = FW_INT_PHY_REQ_LEN;
+   hic.cmd.hdr.checksum = FW_DEFAULT_CHECKSUM;
+   hic.cmd.port_number = hw->bus.lan_id;
+   hic.cmd.command_type = FW_INT_PHY_REQ_READ;
+   hic.cmd.address = IXGBE_CPU_TO_BE16(reg_addr);

-   status = ixgbe_host_interface_command(hw, (u32 *)_cmd,
- sizeof(read_cmd),
+   status = ixgbe_host_interface_command(hw, (u32 *),
+ sizeof(hic.cmd),
  IXGBE_HI_COMMAND_TIMEOUT, true);

/* Extract the register value from the response. */
-   *data = ((struct ixgbe_hic_internal_phy_resp *)_cmd)->read_data;
+   *data = IXGBE_LE32_TO_CPU(hic.rsp.read_data);

return status;
 }
-- 
2.5.0



[dpdk-dev] [PATCH v3 27/30] ixgbe/base: allow setting MAC anti spoofing per VF

2016-06-15 Thread Beilei Xing
Make ixgbe_set_mac_anti_spoofing() consistent with the other
functions that deal with setting VLAN and Ethertype spoofing by
changing the prototype to accept a VF parameter.

Also change the logic for writing the PFVFSPOOF register to be similar
to the MAC and Ethertype functions.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_common.c | 40 ++-
 drivers/net/ixgbe/base/ixgbe_common.h |  2 +-
 2 files changed, 12 insertions(+), 30 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index 6e54628..e1d09e2 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -4203,43 +4203,25 @@ out:
 /**
  *  ixgbe_set_mac_anti_spoofing - Enable/Disable MAC anti-spoofing
  *  @hw: pointer to hardware structure
- *  @enable: enable or disable switch for anti-spoofing
- *  @pf: Physical Function pool - do not enable anti-spoofing for the PF
+ *  @enable: enable or disable switch for MAC anti-spoofing
+ *  @vf: Virtual Function pool - VF Pool to set for MAC anti-spoofing
  *
  **/
-void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf)
+void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf)
 {
-   int j;
-   int pf_target_reg = pf >> 3;
-   int pf_target_shift = pf % 8;
-   u32 pfvfspoof = 0;
+   int vf_target_reg = vf >> 3;
+   int vf_target_shift = vf % 8;
+   u32 pfvfspoof;

if (hw->mac.type == ixgbe_mac_82598EB)
return;

+   pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
if (enable)
-   pfvfspoof = IXGBE_SPOOF_MACAS_MASK;
-
-   /*
-* PFVFSPOOF register array is size 8 with 8 bits assigned to
-* MAC anti-spoof enables in each register array element.
-*/
-   for (j = 0; j < pf_target_reg; j++)
-   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), pfvfspoof);
-
-   /*
-* The PF should be allowed to spoof so that it can support
-* emulation mode NICs.  Do not set the bits assigned to the PF
-*/
-   pfvfspoof &= (1 << pf_target_shift) - 1;
-   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), pfvfspoof);
-
-   /*
-* Remaining pools belong to the PF so they do not need to have
-* anti-spoofing enabled.
-*/
-   for (j++; j < IXGBE_PFVFSPOOF_REG_COUNT; j++)
-   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), 0);
+   pfvfspoof |= (1 << vf_target_shift);
+   else
+   pfvfspoof &= ~(1 << vf_target_shift);
+   IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof);
 }

 /**
diff --git a/drivers/net/ixgbe/base/ixgbe_common.h 
b/drivers/net/ixgbe/base/ixgbe_common.h
index a790ede..0545f85 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.h
+++ b/drivers/net/ixgbe/base/ixgbe_common.h
@@ -148,7 +148,7 @@ s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 
*wwnn_prefix,
 u16 *wwpn_prefix);

 s32 ixgbe_get_fcoe_boot_status_generic(struct ixgbe_hw *hw, u16 *bs);
-void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf);
+void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf);
 void ixgbe_set_vlan_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf);
 s32 ixgbe_get_device_caps_generic(struct ixgbe_hw *hw, u16 *device_caps);
 void ixgbe_set_rxpba_generic(struct ixgbe_hw *hw, int num_pb, u32 headroom,
-- 
2.5.0



[dpdk-dev] [PATCH v3 28/30] ixgbe/base: add flow control autoneg for X550a

2016-06-15 Thread Beilei Xing
This patch adds X550a flow control auto negotiation support.
ixgbe_setup_fc_x550a and ixgbe_fc_autoneg_X550a functions where
added to setup and enable flow control. MAC ops function pointer
fc_autoneg was added so that hardware specific fc autoneg functions
can be called from ixgbe_fc_enable_generic.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_api.h|   2 +
 drivers/net/ixgbe/base/ixgbe_common.c |   5 +-
 drivers/net/ixgbe/base/ixgbe_type.h   |   6 ++
 drivers/net/ixgbe/base/ixgbe_x550.c   | 181 ++
 drivers/net/ixgbe/base/ixgbe_x550.h   |   2 +
 5 files changed, 194 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ixgbe/base/ixgbe_api.h 
b/drivers/net/ixgbe/base/ixgbe_api.h
index c126982..3aad1da 100644
--- a/drivers/net/ixgbe/base/ixgbe_api.h
+++ b/drivers/net/ixgbe/base/ixgbe_api.h
@@ -217,5 +217,7 @@ s32 ixgbe_handle_lasi(struct ixgbe_hw *hw);
 void ixgbe_set_rate_select_speed(struct ixgbe_hw *hw, ixgbe_link_speed speed);
 void ixgbe_disable_rx(struct ixgbe_hw *hw);
 void ixgbe_enable_rx(struct ixgbe_hw *hw);
+s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
+   u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm);

 #endif /* _IXGBE_API_H_ */
diff --git a/drivers/net/ixgbe/base/ixgbe_common.c 
b/drivers/net/ixgbe/base/ixgbe_common.c
index e1d09e2..811875a 100644
--- a/drivers/net/ixgbe/base/ixgbe_common.c
+++ b/drivers/net/ixgbe/base/ixgbe_common.c
@@ -135,6 +135,7 @@ s32 ixgbe_init_ops_generic(struct ixgbe_hw *hw)
/* Flow Control */
mac->ops.fc_enable = ixgbe_fc_enable_generic;
mac->ops.setup_fc = ixgbe_setup_fc_generic;
+   mac->ops.fc_autoneg = ixgbe_fc_autoneg;

/* Link */
mac->ops.get_link_capabilities = NULL;
@@ -2739,7 +2740,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)
}

/* Negotiate the fc mode to use */
-   ixgbe_fc_autoneg(hw);
+   hw->mac.ops.fc_autoneg(hw);

/* Disable any previous flow control settings */
mflcn_reg = IXGBE_READ_REG(hw, IXGBE_MFLCN);
@@ -2849,7 +2850,7 @@ out:
  *  Find the intersection between advertised settings and link partner's
  *  advertised settings
  **/
-STATIC s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
+s32 ixgbe_negotiate_fc(struct ixgbe_hw *hw, u32 adv_reg, u32 lp_reg,
  u32 adv_sym, u32 adv_asm, u32 lp_sym, u32 lp_asm)
 {
if ((!(adv_reg)) ||  (!(lp_reg))) {
diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index 5d76c72..be51bee 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -3886,6 +3886,7 @@ struct ixgbe_mac_operations {
/* Flow Control */
s32 (*fc_enable)(struct ixgbe_hw *);
s32 (*setup_fc)(struct ixgbe_hw *);
+   void (*fc_autoneg)(struct ixgbe_hw *);

/* Manageability interface */
s32 (*set_fw_drv_ver)(struct ixgbe_hw *, u8, u8, u8, u8);
@@ -4131,10 +4132,12 @@ struct ixgbe_hw {
 #define IXGBE_FUSES0_REV_MASK  (3 << 6)

 #define IXGBE_KRM_PORT_CAR_GEN_CTRL(P) ((P) ? 0x8010 : 0x4010)
+#define IXGBE_KRM_LINK_S1(P)   ((P) ? 0x8200 : 0x4200)
 #define IXGBE_KRM_LINK_CTRL_1(P)   ((P) ? 0x820C : 0x420C)
 #define IXGBE_KRM_AN_CNTL_1(P) ((P) ? 0x822C : 0x422C)
 #define IXGBE_KRM_AN_CNTL_8(P) ((P) ? 0x8248 : 0x4248)
 #define IXGBE_KRM_SGMII_CTRL(P)((P) ? 0x82A0 : 0x42A0)
+#define IXGBE_KRM_LP_BASE_PAGE_HIGH(P) ((P) ? 0x836C : 0x436C)
 #define IXGBE_KRM_DSP_TXFFE_STATE_4(P) ((P) ? 0x8634 : 0x4634)
 #define IXGBE_KRM_DSP_TXFFE_STATE_5(P) ((P) ? 0x8638 : 0x4638)
 #define IXGBE_KRM_RX_TRN_LINKUP_CTRL(P)((P) ? 0x8B00 : 0x4B00)
@@ -4156,6 +4159,7 @@ struct ixgbe_hw {
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_CAP_KR   (1 << 18)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KX  (1 << 24)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_EEE_CAP_KR  (1 << 26)
+#define IXGBE_KRM_LINK_S1_MAC_AN_COMPLETE  (1 << 28)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_ENABLE   (1 << 29)
 #define IXGBE_KRM_LINK_CTRL_1_TETH_AN_RESTART  (1 << 31)

@@ -4164,6 +4168,8 @@ struct ixgbe_hw {

 #define IXGBE_KRM_AN_CNTL_8_LINEAR (1 << 0)
 #define IXGBE_KRM_AN_CNTL_8_LIMITING   (1 << 1)
+#define IXGBE_KRM_LP_BASE_PAGE_HIGH_SYM_PAUSE  (1 << 10)
+#define IXGBE_KRM_LP_BASE_PAGE_HIGH_ASM_PAUSE  (1 << 11)

 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_100_D   (1 << 12)
 #define IXGBE_KRM_SGMII_CTRL_MAC_TAR_FORCE_10_D(1 << 19)
diff --git a/drivers/net/ixgbe/base/ixgbe_x550.c 
b/drivers/net/ixgbe/base/ixgbe_x550.c
index 99023e9..ae6b79f 100644
--- a/drivers/net/ixgbe/base/ixgbe_x550.c
+++ b/drivers/net/ixgbe/base/ixgbe_x550.c
@@ -666,6 +666,10 @@ s32 ixgbe_init_ops_X550EM(struct ixgbe_hw *hw)

if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper)

[dpdk-dev] [PATCH v3 29/30] ixgbe/base: define if enable crosstalk work around

2016-06-15 Thread Beilei Xing
A work around for a new crosstalk erratum that causes link flap in
entry cages has been introduced. So this patch defines the bit in
NVM that will tell software if this work around is needed.

Signed-off-by: Beilei Xing 
---
 drivers/net/ixgbe/base/ixgbe_type.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ixgbe/base/ixgbe_type.h 
b/drivers/net/ixgbe/base/ixgbe_type.h
index be51bee..83818a9 100644
--- a/drivers/net/ixgbe/base/ixgbe_type.h
+++ b/drivers/net/ixgbe/base/ixgbe_type.h
@@ -2405,6 +2405,7 @@ enum {
 #define IXGBE_SAN_MAC_ADDR_PORT1_OFFSET0x3
 #define IXGBE_DEVICE_CAPS_ALLOW_ANY_SFP0x1
 #define IXGBE_DEVICE_CAPS_FCOE_OFFLOADS0x2
+#define IXGBE_DEVICE_CAPS_NO_CROSSTALK_WR  (1 << 7)
 #define IXGBE_FW_LESM_PARAMETERS_PTR   0x2
 #define IXGBE_FW_LESM_STATE_1  0x1
 #define IXGBE_FW_LESM_STATE_ENABLED0x8000 /* LESM Enable bit */
-- 
2.5.0



[dpdk-dev] [PATCH v3 30/30] ixgbe/base: update README

2016-06-15 Thread Beilei Xing
The ixgbe base driver was updated refer to version
cid-10g-shared-code.2016.04.12 released by ND.

The changes include:
Added sgmii link for X550.
Added mac link setup for X550a SFP and SFP+.
Added KR support for X550em_a.
Added new phy definitions for M88E1500.
Added support for the VLVF to be bypassed when adding/removing
a VFTA entry.
Added X550a flow control auto negotiation support.

Signed-off-by: Beilei Xing 
---
 doc/guides/rel_notes/release_16_07.rst | 11 +++
 drivers/net/ixgbe/base/README  |  2 +-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index c0f6b02..fa224bc 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -15,6 +15,17 @@ DPDK Release 16.07

   firefox build/doc/html/guides/rel_notes/release_16_07.html

+* **Updated the ixgbe base driver.**
+  The ixgbe base driver was updated with changes including the
+  following:
+
+  * Added sgmii link for X550.
+  * Added mac link setup for X550a SFP and SFP+.
+  * Added KR support for X550em_a.
+  * Added new phy definitions for M88E1500.
+  * Added support for the VLVF to be bypassed when adding/removing a VFTA 
entry.
+  * Added X550a flow control auto negotiation support.
+

 New Features
 
diff --git a/drivers/net/ixgbe/base/README b/drivers/net/ixgbe/base/README
index caa2664..76e7805 100644
--- a/drivers/net/ixgbe/base/README
+++ b/drivers/net/ixgbe/base/README
@@ -34,7 +34,7 @@ Intel? IXGBE driver
 ===

 This directory contains source code of FreeBSD ixgbe driver of version
-cid-10g-shared-code.2016.01.07 released by ND. The sub-directory of base/
+cid-10g-shared-code.2016.04.12 released by ND. The sub-directory of base/
 contains the original source package.
 This driver is valid for the product(s) listed below

-- 
2.5.0



[dpdk-dev] [PATCH v2 00/30] ixgbe/base: update base driver

2016-06-15 Thread Thomas Monjalon
2016-06-15 02:56, Xing, Beilei:
> Can I ignore the two warnings?
> 
> 1) Wrong headline format:
> ixgbe/base: fix firmware commands on X550em_a
> ixgbe/base: add KR support for X550em_a devices
> Seems it's caused by '_' in name ' X550em_a '.

You can ignore these warnings.

> 2) Line too long:
> Fixes: 36f43e8679ae ("ixgbe/base: refactor manageability block 
> communication")
> Fixes: 86b8fb293fdf ("ixgbe/base: add sw-firmware sync for resource 
> sharing on X550em_a")
> Fixline shouldn't be separated into two lines, right?

Yes fixline must be kept on one line.
You can ignore these warnings too.


[dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx callback lists

2016-06-15 Thread Thomas Monjalon
2016-06-15 05:30, Pattan, Reshma:
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> > 2016-06-14 10:38, Reshma Pattan:
> > > Added spinlocks around add/remove logic of Rx and Tx callbacks to
> > > avoid corruption of callback lists in multithreaded context.
> > >
> > > Signed-off-by: Reshma Pattan 
> > 
> > Why cb->next is not locked in burst functions?
> It is safe to do "read access" here and doesn't require any locking as rx/tx 
> burst is initiated  by only local user(control plane) thread.
> 
> > Just protecting add/remove but not its usage seems useless.
> Here locks were required  around add/remove to protect "write access"  
> because write to callback list is now done from 2 threads 
> i.e. one from local user thread(control plane) and another from pdump control 
> thread(initiated by remote pdump request). 

So read and write can be done by different threads.
I think the read access would need locking but we do not want it
in fast path.
Are you sure there is no issue in this design?


[dpdk-dev] [PATCH v9 8/8] doc: update doc for packet capture framework

2016-06-15 Thread Thomas Monjalon
2016-06-15 05:44, Pattan, Reshma:
> > >  ABI Changes
> > >  ---
> > > @@ -146,6 +156,9 @@ ABI Changes
> > >  * The ``rte_port_source_params`` structure has new fields to support PCAP
> > file.
> > >It was already in release 16.04 with ``RTE_NEXT_ABI`` flag.
> > >
> > > +* The ``rte_eth_dev_info`` structure has new fields ``nb_rx_queues`` and
> > ``nb_tx_queues``
> > > +  to support number of queues configured by software.
> > 
> > There was no deprecation notice in 16.04 for this ABI change.
> 
> Deprecation notice and relevant planed changes were sent as RFC during the 
> start of 16.07 , please find the below is the link for the same.
> http://dpdk.org/dev/patchwork/patch/12033/
> http://dpdk.org/dev/patchwork/patch/12034/

Yes there was no notice in 16.04.


[dpdk-dev] [PATCH v3] i40e: fix olflags for vector Rx

2016-06-15 Thread Wu, Jingjing


> -Original Message-
> From: Tao, Zhe
> Sent: Tuesday, June 14, 2016 1:24 PM
> To: dev at dpdk.org
> Cc: Tao, Zhe ; Wu, Jingjing 
> Subject: [PATCH v3] i40e: fix olflags for vector Rx
> 
> Problem:
> The flag for RSS and flow director is not set correctly in the
> vector Rx function, so the upper layer APP which base on the related
> flags will not work correctly.
> 
> Fix this problem by change the shuffle table. the original shuffle
> table is not correct.
> 
> Fixes: 9ed94e5bb04e ("i40e: add vector Rx")
> 
> Signed-off-by: Zhe Tao 

Acked-by: Jingjing Wu 



[dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx callback lists

2016-06-15 Thread Ananyev, Konstantin

Hi Thomas,

> -Original Message-
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Wednesday, June 15, 2016 9:19 AM
> To: Pattan, Reshma
> Cc: dev at dpdk.org; Ananyev, Konstantin
> Subject: Re: [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx 
> callback lists
> 
> 2016-06-15 05:30, Pattan, Reshma:
> > From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> > > 2016-06-14 10:38, Reshma Pattan:
> > > > Added spinlocks around add/remove logic of Rx and Tx callbacks to
> > > > avoid corruption of callback lists in multithreaded context.
> > > >
> > > > Signed-off-by: Reshma Pattan 
> > >
> > > Why cb->next is not locked in burst functions?
> > It is safe to do "read access" here and doesn't require any locking as 
> > rx/tx burst is initiated  by only local user(control plane) thread.
> >
> > > Just protecting add/remove but not its usage seems useless.
> > Here locks were required  around add/remove to protect "write access"  
> > because write to callback list is now done from 2 threads
> > i.e. one from local user thread(control plane) and another from pdump 
> > control thread(initiated by remote pdump request).
> 
> So read and write can be done by different threads.

Yes, and this is possible even in current DPDK version (16.04).
What is added by Reshma's patch - now it is possible to have concurrent write
from 2 different thread to that list.  

> I think the read access would need locking but we do not want it
> in fast path.

I don't think it would be needed.
As I said - read/write interaction didn't change from what we have right now.
But if you have some particular scenario in mind that you believe would cause
a race condition - please speak up.  
Konstantin

> Are you sure there is no issue in this design?




[dpdk-dev] [PATCH 1/1] vhost: fix null pointer dereference

2016-06-15 Thread Marcin Kerlin
Return value of function get_device() is not checking before
dereference. Fix this problem by adding checking condition.

Coverity issue: 119262
Fixes: 77d20126b4c2 ("vhost-user: handle message to enable vring")

Signed-off-by: Marcin Kerlin 
---
 lib/librte_vhost/vhost_user/virtio-net-user.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.c 
b/lib/librte_vhost/vhost_user/virtio-net-user.c
index f5248bc..94959f2 100644
--- a/lib/librte_vhost/vhost_user/virtio-net-user.c
+++ b/lib/librte_vhost/vhost_user/virtio-net-user.c
@@ -332,9 +332,13 @@ int
 user_set_vring_enable(struct vhost_device_ctx ctx,
  struct vhost_vring_state *state)
 {
-   struct virtio_net *dev = get_device(ctx);
+   struct virtio_net *dev;
int enable = (int)state->num;

+   dev = get_device(ctx);
+   if (dev == NULL)
+   return -1;
+
RTE_LOG(INFO, VHOST_CONFIG,
"set queue enable: %d to qp idx: %d\n",
enable, state->index);
-- 
1.9.1



[dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx callback lists

2016-06-15 Thread Thomas Monjalon
2016-06-15 08:37, Ananyev, Konstantin:
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> > 2016-06-15 05:30, Pattan, Reshma:
> > > From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> > > > 2016-06-14 10:38, Reshma Pattan:
> > > > > Added spinlocks around add/remove logic of Rx and Tx callbacks to
> > > > > avoid corruption of callback lists in multithreaded context.
> > > > >
> > > > > Signed-off-by: Reshma Pattan 
> > > >
> > > > Why cb->next is not locked in burst functions?
> > > It is safe to do "read access" here and doesn't require any locking as 
> > > rx/tx burst is initiated  by only local user(control plane) thread.
> > >
> > > > Just protecting add/remove but not its usage seems useless.
> > > Here locks were required  around add/remove to protect "write access"  
> > > because write to callback list is now done from 2 threads
> > > i.e. one from local user thread(control plane) and another from pdump 
> > > control thread(initiated by remote pdump request).
> > 
> > So read and write can be done by different threads.
> 
> Yes, and this is possible even in current DPDK version (16.04).
> What is added by Reshma's patch - now it is possible to have concurrent write
> from 2 different thread to that list.  
> 
> > I think the read access would need locking but we do not want it
> > in fast path.
> 
> I don't think it would be needed.
> As I said - read/write interaction didn't change from what we have right now.
> But if you have some particular scenario in mind that you believe would cause
> a race condition - please speak up.  

If we add/remove a callback during a burst? Is it possible that the next
pointer would have a wrong value leading to a crash?
Maybe we need a comment to state that we should not alter burst
callbacks while running burst functions.


[dpdk-dev] [PATCH v2 1/1] eal: fix resource leak of mapped memory

2016-06-15 Thread Sergio Gonzalez Monroy
Hi Marcin,

On 14/06/2016 16:33, Marcin Kerlin wrote:
> Patch fixes resource leak in rte_eal_hugepage_attach() where mapped files
> were not freed back to the OS in case of failure. Patch uses the behavior
> of Linux munmap: "It is not an error if the indicated range does not
> contain any mapped pages".
>
> Coverity issue: 13295, 13296, 13303
> Fixes: af75078fece3 ("first public release")
>
> Signed-off-by: Marcin Kerlin 
> ---
>   lib/librte_eal/linuxapp/eal/eal_memory.c | 11 +--
>   1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c 
> b/lib/librte_eal/linuxapp/eal/eal_memory.c
> index 79d1d2d..1834fa0 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
> @@ -1417,7 +1417,7 @@ rte_eal_hugepage_attach(void)
>   if (internal_config.xen_dom0_support) {
>   #ifdef RTE_LIBRTE_XEN_DOM0
>   if (rte_xen_dom0_memory_attach() < 0) {
> - RTE_LOG(ERR, EAL,"Failed to attach memory setments of 
> primay "
> + RTE_LOG(ERR, EAL, "Failed to attach memory segments of 
> primary "
>   "process\n");

If you want to fix spelling of error message it probably should go in a 
different patch.

>   return -1;
>   }
> @@ -1481,7 +1481,7 @@ rte_eal_hugepage_attach(void)
>   
>   size = getFileSize(fd_hugepage);
>   hp = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd_hugepage, 0);
> - if (hp == NULL) {
> + if (hp == MAP_FAILED) {
>   RTE_LOG(ERR, EAL, "Could not mmap %s\n", 
> eal_hugepage_info_path());
>   goto error;
>   }
> @@ -1551,6 +1551,13 @@ rte_eal_hugepage_attach(void)
>   return 0;
>   
>   error:
> + s = 0;
> + while (s < RTE_MAX_MEMSEG && mcfg->memseg[s].len > 0) {
> + munmap(mcfg->memseg[s].addr, mcfg->memseg[s].len);
> + s++;
> + }
> + if (hp != NULL && hp != MAP_FAILED)
> + munmap((void *)(uintptr_t)hp, size);

No need for double casting, nor to cast to (void *).

Sergio

>   if (fd_zero >= 0)
>   close(fd_zero);
>   if (fd_hugepage >= 0)




[dpdk-dev] [PATCH 1/1] vhost: fix null pointer dereference

2016-06-15 Thread Yuanhan Liu
On Wed, Jun 15, 2016 at 11:47:22AM +0200, Marcin Kerlin wrote:
> Return value of function get_device() is not checking before
> dereference. Fix this problem by adding checking condition.
> 
> Coverity issue: 119262
> Fixes: 77d20126b4c2 ("vhost-user: handle message to enable vring")
> 
> Signed-off-by: Marcin Kerlin 

Applied to dpdk-next-virtio.

Thanks.

--yliu


[dpdk-dev] [PATCH v9 1/6] virtio: hide phys addr check inside PCI ops

2016-06-15 Thread Jianfeng Tan
This patch is to move phys addr check from virtio_dev_queue_setup
to pci ops. To makt that happen, make sure virtio_ops.setup_queue
return the result if we pass through the check.

Signed-off-by: Jianfeng Tan 
Signed-off-by: Huawei Xie 
Acked-by: Yuanhan Liu 
---
 drivers/net/virtio/virtio_ethdev.c | 17 ++---
 drivers/net/virtio/virtio_pci.c| 30 --
 drivers/net/virtio/virtio_pci.h|  2 +-
 3 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index ad0f5a6..53faa46 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -388,16 +388,6 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
}
}

-   /*
-* Virtio PCI device VIRTIO_PCI_QUEUE_PF register is 32bit,
-* and only accepts 32 bit page frame number.
-* Check if the allocated physical memory exceeds 16TB.
-*/
-   if ((mz->phys_addr + vq->vq_ring_size - 1) >> 
(VIRTIO_PCI_QUEUE_ADDR_SHIFT + 32)) {
-   PMD_INIT_LOG(ERR, "vring address shouldn't be above 16TB!");
-   ret = -ENOMEM;
-   goto fail_q_alloc;
-   }
memset(mz->addr, 0, sizeof(mz->len));

vq->vq_ring_mem = mz->phys_addr;
@@ -482,7 +472,12 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
*pvq = cvq;
}

-   hw->vtpci_ops->setup_queue(hw, vq);
+   if (hw->vtpci_ops->setup_queue(hw, vq) < 0) {
+   PMD_INIT_LOG(ERR, "setup_queue failed");
+   virtio_dev_queue_release(vq);
+   return -EINVAL;
+   }
+
vq->configured = 1;
return 0;

diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index 60ec4da..02f605d 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -55,6 +55,22 @@
  */
 #define VIRTIO_PCI_CONFIG(hw) (((hw)->use_msix) ? 24 : 20)

+static inline int
+check_vq_phys_addr_ok(struct virtqueue *vq)
+{
+   /* Virtio PCI device VIRTIO_PCI_QUEUE_PF register is 32bit,
+* and only accepts 32 bit page frame number.
+* Check if the allocated physical memory exceeds 16TB.
+*/
+   if ((vq->vq_ring_mem + vq->vq_ring_size - 1) >>
+   (VIRTIO_PCI_QUEUE_ADDR_SHIFT + 32)) {
+   PMD_INIT_LOG(ERR, "vring address shouldn't be above 16TB!");
+   return 0;
+   }
+
+   return 1;
+}
+
 static void
 legacy_read_dev_config(struct virtio_hw *hw, size_t offset,
   void *dst, int length)
@@ -143,15 +159,20 @@ legacy_get_queue_num(struct virtio_hw *hw, uint16_t 
queue_id)
return dst;
 }

-static void
+static int
 legacy_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)
 {
uint32_t src;

+   if (!check_vq_phys_addr_ok(vq))
+   return -1;
+
rte_eal_pci_ioport_write(>io, >vq_queue_index, 2,
 VIRTIO_PCI_QUEUE_SEL);
src = vq->vq_ring_mem >> VIRTIO_PCI_QUEUE_ADDR_SHIFT;
rte_eal_pci_ioport_write(>io, , 4, VIRTIO_PCI_QUEUE_PFN);
+
+   return 0;
 }

 static void
@@ -367,12 +388,15 @@ modern_get_queue_num(struct virtio_hw *hw, uint16_t 
queue_id)
return io_read16(>common_cfg->queue_size);
 }

-static void
+static int
 modern_setup_queue(struct virtio_hw *hw, struct virtqueue *vq)
 {
uint64_t desc_addr, avail_addr, used_addr;
uint16_t notify_off;

+   if (!check_vq_phys_addr_ok(vq))
+   return -1;
+
desc_addr = vq->vq_ring_mem;
avail_addr = desc_addr + vq->vq_nentries * sizeof(struct vring_desc);
used_addr = RTE_ALIGN_CEIL(avail_addr + offsetof(struct vring_avail,
@@ -400,6 +424,8 @@ modern_setup_queue(struct virtio_hw *hw, struct virtqueue 
*vq)
PMD_INIT_LOG(DEBUG, "\t used_addr: %" PRIx64, used_addr);
PMD_INIT_LOG(DEBUG, "\t notify addr: %p (notify offset: %u)",
vq->notify_addr, notify_off);
+
+   return 0;
 }

 static void
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index f20468a..6c7f8d7 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -235,7 +235,7 @@ struct virtio_pci_ops {
uint16_t (*set_config_irq)(struct virtio_hw *hw, uint16_t vec);

uint16_t (*get_queue_num)(struct virtio_hw *hw, uint16_t queue_id);
-   void (*setup_queue)(struct virtio_hw *hw, struct virtqueue *vq);
+   int (*setup_queue)(struct virtio_hw *hw, struct virtqueue *vq);
void (*del_queue)(struct virtio_hw *hw, struct virtqueue *vq);
void (*notify_queue)(struct virtio_hw *hw, struct virtqueue *vq);
 };
-- 
2.1.4



[dpdk-dev] [PATCH v9 4/6] virtio-user: add device emulation layer APIs

2016-06-15 Thread Jianfeng Tan
Two device emulation layer APIs are added for virtio driver to call:
  - virtio_user_start_device()
  - virtio_user_stop_device()
  - virtio_user_dev_init()
  - virtio_user_dev_uninit()

These APIs will get called by virtio driver, and they call vhost adapter
layer APIs to implement the functionality. Besides, this patch defines
a struct named virtio_user_dev to help manage the data stands for this
kind of virtual device.

  --
  | -- |
  | | virtio driver  | |
  | -- |
  | |  |
  | -- | -->  virtio-user PMD
  | | device emulate |-|> (virtio_user_dev.c, virtio_user_dev.h)
  | || |
  | | vhost adapter  | |
  | -- |
  --
|
|
|
   --
   | vhost backend  |
   --

Signed-off-by: Huawei Xie 
Signed-off-by: Jianfeng Tan 
Acked-by: Neil Horman 
---
 drivers/net/virtio/Makefile  |   1 +
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 227 +++
 drivers/net/virtio/virtio_user/virtio_user_dev.h |  62 +++
 3 files changed, 290 insertions(+)
 create mode 100644 drivers/net/virtio/virtio_user/virtio_user_dev.c
 create mode 100644 drivers/net/virtio/virtio_user/virtio_user_dev.h

diff --git a/drivers/net/virtio/Makefile b/drivers/net/virtio/Makefile
index c2ed0fa..d37b83d 100644
--- a/drivers/net/virtio/Makefile
+++ b/drivers/net/virtio/Makefile
@@ -57,6 +57,7 @@ endif

 ifeq ($(CONFIG_RTE_VIRTIO_USER),y)
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user/vhost_user.c
+SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user/virtio_user_dev.c
 endif

 # this lib depends upon:
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c 
b/drivers/net/virtio/virtio_user/virtio_user_dev.c
new file mode 100644
index 000..93cb758
--- /dev/null
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -0,0 +1,227 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   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
+ *   OWNER 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "vhost.h"
+#include "virtio_user_dev.h"
+#include "../virtio_ethdev.h"
+
+static int
+virtio_user_kick_queue(struct virtio_user_dev *dev, uint32_t queue_sel)
+{
+   int callfd, kickfd;
+   struct vhost_vring_file file;
+   struct vhost_vring_state state;
+   struct vring *vring = >vrings[queue_sel];
+   struct vhost_vring_addr addr = {
+   .index = queue_sel,
+   .desc_user_addr = (uint64_t)(uintptr_t)vring->desc,
+   .avail_user_addr = (uint64_t)(uintptr_t)vring->avail,
+   .used_user_addr = (uint64_t)(uintptr_t)vring->used,
+   .log_guest_addr = 0,
+   .flags = 0, /* disable log */
+   };
+
+   /* May use invalid flag, but some backend leverages kickfd and callfd as
+* criteria to judge if dev is alive. so finally we use real event_fd.
+*/
+   callfd = eventfd(0, O_CLOEXEC | O_NONBLOCK);
+   if (callfd < 0) {
+   PMD_DRV_LOG(ERR, "callfd error, %s\n", strerror(errno));
+   return -1;
+   }
+   kickfd = eventfd(0, O_CLOEXEC | O_NONBLOCK);
+   if (kickfd < 0) {
+   close(callfd);
+   

[dpdk-dev] [PATCH v9 5/6] virtio-user: add new virtual PCI driver for virtio

2016-06-15 Thread Jianfeng Tan
This patch implements another new instance of struct virtio_pci_ops to
drive the virtio-user virtual device. Instead of rd/wr ioport or PCI
configuration space, this virtual pci driver will rd/wr the virtual
device struct virtio_user_hw, and when necessary, invokes APIs provided
by device emulation later to start/stop the device.

  --
  | -- |
  | | virtio driver  | |> (virtio_user_ethdev.c)
  | -- |
  | |  |
  | -- | -->  virtio-user PMD
  | | device emulate | |
  | || |
  | | vhost adapter  | |
  | -- |
  --
|
|
|
   --
   | vhost backend  |
   --

Signed-off-by: Huawei Xie 
Signed-off-by: Jianfeng Tan 
Acked-by: Neil Horman 
Acked-by: Yuanhan Liu 
---
 drivers/net/virtio/Makefile |   1 +
 drivers/net/virtio/virtio_pci.h |   1 +
 drivers/net/virtio/virtio_user_ethdev.c | 218 
 3 files changed, 220 insertions(+)
 create mode 100644 drivers/net/virtio/virtio_user_ethdev.c

diff --git a/drivers/net/virtio/Makefile b/drivers/net/virtio/Makefile
index d37b83d..43de46c 100644
--- a/drivers/net/virtio/Makefile
+++ b/drivers/net/virtio/Makefile
@@ -58,6 +58,7 @@ endif
 ifeq ($(CONFIG_RTE_VIRTIO_USER),y)
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user/vhost_user.c
 SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user/virtio_user_dev.c
+SRCS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio_user_ethdev.c
 endif

 # this lib depends upon:
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index 6c7f8d7..dd7693f 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -261,6 +261,7 @@ struct virtio_hw {
struct virtio_pci_common_cfg *common_cfg;
struct virtio_net_config *dev_cfg;
const struct virtio_pci_ops *vtpci_ops;
+   void*virtio_user_dev;
 };

 /*
diff --git a/drivers/net/virtio/virtio_user_ethdev.c 
b/drivers/net/virtio/virtio_user_ethdev.c
new file mode 100644
index 000..7814514
--- /dev/null
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -0,0 +1,218 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Intel Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   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
+ *   OWNER 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 
+#include 
+#include 
+
+#include "virtio_logs.h"
+#include "virtio_pci.h"
+#include "virtqueue.h"
+#include "virtio_user/virtio_user_dev.h"
+
+#define virtio_user_get_dev(hw) \
+   ((struct virtio_user_dev *)(hw)->virtio_user_dev);
+
+static void
+virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset,
+void *dst, int length)
+{
+   int i;
+   struct virtio_user_dev *dev = virtio_user_get_dev(hw);
+
+   if (offset == offsetof(struct virtio_net_config, mac) &&
+   length == ETHER_ADDR_LEN) {
+   for (i = 0; i < ETHER_ADDR_LEN; ++i)
+   ((uint8_t *)dst)[i] = dev->mac_addr[i];
+   return;
+   }
+
+   if (offset == offsetof(struct virtio_net_config, status))
+   *(uint16_t *)dst = dev->status;
+
+   if (offset == offsetof(struct virtio_net_config, max_virtqueue_pairs))
+   *(uint16_t *)dst = dev->max_queue_pairs;
+}
+
+static void
+virtio_user_write_dev_config(struct 

[dpdk-dev] [PATCH v9 6/6] virtio-user: add a new vdev named virtio-user

2016-06-15 Thread Jianfeng Tan
Add a new virtual device named vhost-user, which can be used just like
eth_ring, eth_null, etc. To reuse the code of original virtio, we do
some adjustment in virtio_ethdev.c, such as remove key _static_ of
eth_virtio_dev_init() so that it can be reused in virtual device; and
we add some check to make sure it will not crash.

Configured parameters include:
  - queues (optional, 1 by default), number of queue pairs, multi-queue
not supported for now.
  - cq (optional, 0 by default), not supported for now.
  - mac (optional), random value will be given if not specified.
  - queue_size (optional, 256 by default), size of virtqueues.
  - path (madatory), path of vhost user.

When enable CONFIG_RTE_VIRTIO_USER (enabled by default), the compiled
library can be used in both VM and container environment.

Examples:
path_vhost= # use vhost-user as a backend

sudo ./examples/l2fwd/build/l2fwd -c 0x10 -n 4 \
--socket-mem 0,1024 --no-pci --file-prefix=l2fwd \
--vdev=virtio-user0,mac=00:01:02:03:04:05,path=$path_vhost -- -p 0x1

Known issues:
 - Control queue and multi-queue are not supported yet.
 - Cannot work with --huge-unlink.
 - Cannot work with no-huge.
 - Cannot work when there are more than VHOST_MEMORY_MAX_NREGIONS(8)
   hugepages.
 - Root privilege is a must (mainly becase of sorting hugepages according
   to physical address).
 - Applications should not use file name like HUGEFILE_FMT ("%smap_%d").
 - Cannot work with vhost-net backend.

Signed-off-by: Huawei Xie 
Signed-off-by: Jianfeng Tan 
Acked-by: Neil Horman 
Acked-by: Yuanhan Liu 
---
 doc/guides/rel_notes/release_16_07.rst  |  12 ++
 doc/guides/sample_app_ug/vhost.rst  |  17 +++
 drivers/net/virtio/virtio_ethdev.c  |  19 +--
 drivers/net/virtio/virtio_ethdev.h  |   2 +
 drivers/net/virtio/virtio_user_ethdev.c | 209 
 5 files changed, 252 insertions(+), 7 deletions(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index 13df729..681235a 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -68,6 +68,18 @@ New Features

   It can be turned off if flag ``RTE_VHOST_USER_NO_RECONNECT`` is set.

+* **Virtio support for containers.**
+
+  Add a new virtual device, named virtio-user, to support virtio for 
containers.
+
+  Known limitations:
+
+  * Control queue and multi-queue are not supported yet.
+  * Cannot work with --huge-unlink.
+  * Cannot work with --no-huge.
+  * Cannot work when there are more than VHOST_MEMORY_MAX_NREGIONS(8) 
hugepages.
+  * Root privilege is a must for sorting hugepages by physical address.
+  * Can only be used with vhost user backend.

 Resolved Issues
 ---
diff --git a/doc/guides/sample_app_ug/vhost.rst 
b/doc/guides/sample_app_ug/vhost.rst
index 5f81802..a93e54d 100644
--- a/doc/guides/sample_app_ug/vhost.rst
+++ b/doc/guides/sample_app_ug/vhost.rst
@@ -833,3 +833,20 @@ For example:
 The above message indicates that device 0 has been registered with MAC address 
cc:bb:bb:bb:bb:bb and VLAN tag 1000.
 Any packets received on the NIC with these values is placed on the devices 
receive queue.
 When a virtio-net device transmits packets, the VLAN tag is added to the 
packet by the DPDK vhost sample code.
+
+Running virtio-user with vhost-switch
+-
+
+We can also use virtio-user with vhost-switch now.
+Virtio-user is a virtual device that can be run in a application (container) 
parallelly with vhost in the same OS,
+aka, there is no need to start a VM. We just run it with a different 
--file-prefix to avoid startup failure.
+
+.. code-block:: console
+
+cd ${RTE_SDK}/x86_64-native-linuxapp-gcc/app
+./testpmd -c 0x3 -n 4 --socket-mem 1024 --no-pci 
--file-prefix=virtio-user-testpmd \
+--vdev=virtio-user0,mac=00:01:02:03:04:05,path=$path_vhost \
+-- -i --txqflags=0xf01 --disable-hw-vlan
+
+There is no difference on the vhost side.
+Pleae note that there are some limitations (see release note for more 
information) in the usage of virtio-user.
diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 5fd9f51..026b8a1 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -59,7 +59,6 @@
 #include "virtqueue.h"
 #include "virtio_rxtx.h"

-static int eth_virtio_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev);
 static int  virtio_dev_configure(struct rte_eth_dev *dev);
 static int  virtio_dev_start(struct rte_eth_dev *dev);
@@ -1084,7 +1083,7 @@ rx_func_get(struct rte_eth_dev *eth_dev)
  * This function is based on probe() function in virtio_pci.c
  * It returns 0 on success.
  */
-static int
+int
 eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 {
struct virtio_hw *hw = eth_dev->data->dev_private;
@@ -1115,9 +1114,11 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)

pci_dev = 

[dpdk-dev] [PATCH v9 5/8] pdump: add new library for packet capturing support

2016-06-15 Thread Mcnamara, John
> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Thomas Monjalon
> Sent: Tuesday, June 14, 2016 9:28 PM
> To: Pattan, Reshma 
> Cc: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v9 5/8] pdump: add new library for packet
> capturing support
> 
> 2016-06-14 10:38, Reshma Pattan:
> > The new librte_pdump library is added for packet capturing support.
> >
> 
> And more importantly, we need a doc in the prog guide.
> 

Hi Thomas,

The Programmers Guide update is in another part of the patchset. Can we get 
some clarification on the requirements for documentation within patchset?

Should all documentation related to a feature be in the patch for the feature? 
From your recent comments on patches it looks like that is the way you prefer 
it. That is fine but there is some confusion because it seems that wasn't 
always a requirement in the past so it would be best to clarify, and preferably 
document this.

Also, it makes it a bit harder for the documentation maintainer (me in this 
case) to see doc changes within patches and to ack just the doc part. From a 
documentation maintainer point of view it would be best to have any, 
non-trivial, doc changes in a separate patch.

John



[dpdk-dev] [PATCH v3 0/3] add multi queue support for virtio-user

2016-06-15 Thread Jianfeng Tan
v3:
  - Fix compiling issue on 32-bit system.
  - Fix a segment fault issue when sending VHOST_USER_SET_VRING_ENABLE.
  - Squash the patch (use virtual address in mq) into "virtio for container"
patch series.

v2:
  - Move the ctrl queue handler and multi queue logic into device emulation.
  - Rebase on newest code.

This patch set depends on below patch sets:
  - http://dpdk.org/ml/archives/dev/2016-April/038111.html
  - http://dpdk.org/ml/archives/dev/2016-April/038118.html
  - http://dpdk.org/ml/archives/dev/2016-April/038121.html

Add multi queue support for virtio-user virtual port. Patch 1 adds vhost
user adapter communications for enable/disable queues. Patch 2 adds features
check for multi queue and provides a method for virtio-user driver to
enable/disable queues. Patch 3 partially implements ctrl-q to handle
VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET command from PMD.

Test case:
1. start testpmd with a vhost-user port:
 $ TESTPMD -c 0x7 -n 4 --socket-mem 1024,0 --no-pci \
  --vdev 'eth_vhost0,iface=/tmp/sock0,queues=2' \
  -- -i --rxq=2 --txq=2 --nb-cores=2
2. start testpmd with a virtio-user port:
 $ TESTPMD -c 0x70 -n 4 --socket-mem 1024,0 --no-pci --file-prefix=testpmd \
  --vdev=virtio-user0,mac=00:01:02:03:04:05,path=/tmp/sock0,queues=2 \
  -- -i --rxq=2 --txq=2 --nb-cores=2 --txqflags=0xf01 --disable-hw-vlan
3. use below commands to see if all queues are working:
 testpmd> show port xstats all


Jianfeng Tan (3):
  virtio-user: add mq in vhost user adapter
  virtio-user: add ctrl-q and mq in device emulation
  virtio-user: handle ctrl-q in driver

 drivers/net/virtio/virtio_user/vhost.h   |   5 +
 drivers/net/virtio/virtio_user/vhost_user.c  |  22 
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 124 +--
 drivers/net/virtio/virtio_user/virtio_user_dev.h |   2 +-
 drivers/net/virtio/virtio_user_ethdev.c  |  13 +++
 5 files changed, 156 insertions(+), 10 deletions(-)

-- 
2.1.4



[dpdk-dev] [PATCH v3 1/3] virtio-user: add mq in vhost user adapter

2016-06-15 Thread Jianfeng Tan
This patch mainly adds method in vhost user adapter to communicate
enable/disable queues messages with vhost user backend, aka,
VHOST_USER_SET_VRING_ENABLE.

Signed-off-by: Jianfeng Tan 
---
 drivers/net/virtio/virtio_user/vhost.h  |  5 +
 drivers/net/virtio/virtio_user/vhost_user.c | 22 ++
 2 files changed, 27 insertions(+)

diff --git a/drivers/net/virtio/virtio_user/vhost.h 
b/drivers/net/virtio/virtio_user/vhost.h
index 4e04ede..8d1e505 100644
--- a/drivers/net/virtio/virtio_user/vhost.h
+++ b/drivers/net/virtio/virtio_user/vhost.h
@@ -136,6 +136,11 @@ struct vhost_user_msg {
 /* The version of the protocol we support */
 #define VHOST_USER_VERSION0x1

+#define VHOST_USER_F_PROTOCOL_FEATURES 30
+#define VHOST_USER_MQ (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)
+
 int vhost_user_sock(int vhostfd, uint64_t req, void *arg);
 int vhost_user_setup(const char *path);
+int vhost_user_enable_queue_pair(int vhostfd, unsigned pair_idx, int enable);
+
 #endif
diff --git a/drivers/net/virtio/virtio_user/vhost_user.c 
b/drivers/net/virtio/virtio_user/vhost_user.c
index 47bbf74..98d98b6 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -234,6 +234,7 @@ static const char * const vhost_msg_strings[] = {
[VHOST_USER_SET_VRING_ADDR] = "VHOST_USER_SET_VRING_ADDR",
[VHOST_USER_SET_VRING_KICK] = "VHOST_USER_SET_VRING_KICK",
[VHOST_USER_SET_MEM_TABLE] = "VHOST_USER_SET_MEM_TABLE",
+   [VHOST_USER_SET_VRING_ENABLE] = "VHOST_USER_SET_VRING_ENABLE",
NULL,
 };

@@ -286,6 +287,7 @@ vhost_user_sock(int vhostfd, uint64_t req, void *arg)

case VHOST_USER_SET_VRING_NUM:
case VHOST_USER_SET_VRING_BASE:
+   case VHOST_USER_SET_VRING_ENABLE:
memcpy(, arg, sizeof(msg.payload.state));
msg.size = sizeof(m.payload.state);
break;
@@ -402,3 +404,23 @@ vhost_user_setup(const char *path)

return fd;
 }
+
+int
+vhost_user_enable_queue_pair(int vhostfd, unsigned pair_idx, int enable)
+{
+   int i;
+
+   for (i = 0; i < 2; ++i) {
+   struct vhost_vring_state state = {
+   .index = pair_idx * 2 + i,
+   .num   = enable,
+   };
+
+   if (vhost_user_sock(vhostfd,
+   VHOST_USER_SET_VRING_ENABLE, ))
+   return -1;
+   }
+
+   return 0;
+
+}
-- 
2.1.4



[dpdk-dev] [PATCH v3 2/3] virtio-user: add ctrl-q and mq in device emulation

2016-06-15 Thread Jianfeng Tan
The main purpose of this patch is to enable multi-queue. But
multi-queue requires ctrl-queue so that driver can send how many
queues will be enabled through ctrl-queue messages.

So we partially implement ctrl-queue to handle control command with class
of VIRTIO_NET_CTRL_MQ and with cmd of VIRTIO_NET_CTRL_MQ_VQ_PAIRS_SET
to handle mq support. This patch provides an API, virtio_user_handle_cq(),
for driver to handle ctrl-queue messages.

Besides, multi-queue requires VIRTIO_NET_F_MQ and VIRTIO_NET_F_CTRL_VQ
are enabled when we do feature negotiation.

Signed-off-by: Jianfeng Tan 
---
 drivers/net/virtio/virtio_user/virtio_user_dev.c | 124 +--
 drivers/net/virtio/virtio_user/virtio_user_dev.h |   2 +-
 2 files changed, 116 insertions(+), 10 deletions(-)

diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c 
b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 93cb758..3d12a32 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -131,11 +131,14 @@ virtio_user_start_device(struct virtio_user_dev *dev)
}
}

-   /* After setup all virtqueues, we need to set_features so that
-* these features can be set into each virtqueue in vhost side.
-* And before that, make sure VIRTIO_NET_F_MAC is stripped.
+   /* After setup all virtqueues, we need to set_features so that these
+* features can be set into each virtqueue in vhost side. And before
+* that, make sure VHOST_USER_F_PROTOCOL_FEATURES is added if mq is
+* enabled, and VIRTIO_NET_F_MAC is stripped.
 */
features = dev->features;
+   if (dev->max_queue_pairs > 1)
+   features |= VHOST_USER_MQ;
features &= ~(1ull << VIRTIO_NET_F_MAC);
ret = vhost_user_sock(dev->vhostfd, VHOST_USER_SET_FEATURES, );
if (ret < 0)
@@ -185,8 +188,6 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char 
*path, int queues,
dev->mac_specified = 0;
parse_mac(dev, mac);
dev->vhostfd = -1;
-   /* TODO: cq */
-   RTE_SET_USED(cq);

dev->vhostfd = vhost_user_setup(dev->path);
if (dev->vhostfd < 0) {
@@ -205,12 +206,33 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char 
*path, int queues,
}
if (dev->mac_specified)
dev->features |= (1ull << VIRTIO_NET_F_MAC);
-   /* disable it until we support CQ */
-   dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
-   dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_RX);

-   return 0;
+   if (!cq) {
+   dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ);
+   /* Also disable features depends on VIRTIO_NET_F_CTRL_VQ */
+   dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_RX);
+   dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN);
+   dev->features &= ~(1ull << VIRTIO_NET_F_GUEST_ANNOUNCE);
+   dev->features &= ~(1ull << VIRTIO_NET_F_MQ);
+   dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR);
+   } else {
+   /* vhost user backend does not need to know ctrl-q, so
+* actually we need add this bit into features. However,
+* DPDK vhost-user does send features with this bit, so we
+* check it instead of OR it for now.
+*/
+   if (!(dev->features & (1ull << VIRTIO_NET_F_CTRL_VQ)))
+   PMD_INIT_LOG(INFO, "vhost does not support ctrl-q");
+   }
+
+   if (dev->max_queue_pairs > 1) {
+   if (!(dev->features & VHOST_USER_MQ)) {
+   PMD_INIT_LOG(ERR, "MQ not supported by the backend");
+   return -1;
+   }
+   }

+   return 0;
 }

 void
@@ -225,3 +247,87 @@ virtio_user_dev_uninit(struct virtio_user_dev *dev)

close(dev->vhostfd);
 }
+
+static uint8_t
+virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t q_pairs)
+{
+   uint16_t i;
+   uint8_t ret = 0;
+
+   if (q_pairs > dev->max_queue_pairs) {
+   PMD_INIT_LOG(ERR, "multi-q config %u, but only %u supported",
+q_pairs, dev->max_queue_pairs);
+   return -1;
+   }
+
+   for (i = 0; i < q_pairs; ++i)
+   ret |= vhost_user_enable_queue_pair(dev->vhostfd, i, 1);
+   for (i = q_pairs; i < dev->max_queue_pairs; ++i)
+   ret |= vhost_user_enable_queue_pair(dev->vhostfd, i, 0);
+
+   dev->queue_pairs = q_pairs;
+
+   return ret;
+}
+
+static uint32_t
+virtio_user_handle_ctrl_msg(struct virtio_user_dev *dev, struct vring *vring,
+   uint16_t idx_hdr)
+{
+   struct virtio_net_ctrl_hdr *hdr;
+   virtio_net_ctrl_ack status = ~0;
+   uint16_t i, idx_data, idx_status;
+   uint32_t n_descs = 0;
+
+   /* locate desc for header, data, and status */
+   idx_data = 

[dpdk-dev] [PATCH v3 0/3] virtio-user: handle ctrl-q in driver

2016-06-15 Thread Jianfeng Tan
In virtio-user driver, when notify ctrl-queue, invoke API of
virtio-user device emulation to handle ctrl-q command.

Besides, multi-queue requires ctrl-queue and ctrl-queue will be
enabled automatically when multi-queue is specified.

Signed-off-by: Jianfeng Tan 
---
 drivers/net/virtio/virtio_user_ethdev.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/net/virtio/virtio_user_ethdev.c 
b/drivers/net/virtio/virtio_user_ethdev.c
index 8f401a3..4c9279e 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -42,6 +42,7 @@
 #include "virtio_logs.h"
 #include "virtio_pci.h"
 #include "virtqueue.h"
+#include "virtio_rxtx.h"
 #include "virtio_user/virtio_user_dev.h"

 #define virtio_user_get_dev(hw) \
@@ -200,6 +201,11 @@ virtio_user_notify_queue(struct virtio_hw *hw, struct 
virtqueue *vq)
uint64_t buf = 1;
struct virtio_user_dev *dev = virtio_user_get_dev(hw);

+   if (hw->cvq && (hw->cvq->vq == vq)) {
+   virtio_user_handle_cq(dev, vq->vq_queue_index);
+   return;
+   }
+
if (write(dev->kickfds[vq->vq_queue_index], , sizeof(buf)) < 0)
PMD_DRV_LOG(ERR, "failed to kick backend: %s\n",
strerror(errno));
@@ -360,6 +366,13 @@ virtio_user_pmd_devinit(const char *name, const char 
*params)
if (rte_kvargs_count(kvlist, VIRTIO_USER_ARG_CQ_NUM) == 1)
rte_kvargs_process(kvlist, VIRTIO_USER_ARG_CQ_NUM,
   _integer_arg, );
+   else if (queues > 1)
+   cq = 1;
+
+   if (queues > 1 && cq == 0) {
+   PMD_INIT_LOG(ERR, "multi-q requires ctrl-q");
+   goto end;
+   }

eth_dev = virtio_user_eth_dev_alloc(name);
if (!eth_dev) {
-- 
2.1.4



[dpdk-dev] [PATCH v4 7/8] rte: change xstats usage to new API

2016-06-15 Thread Thomas Monjalon
2016-06-13 16:52, Remy Horton:
> The current extended ethernet statistics fetching involve doing several
> string operations, which causes performance issues if there are lots of
> statistics and/or network interfaces. This patch changes the test-pmd
> and proc_info applications to use the new xstats API, and removes
> deprecated code associated with the old API.

There is something wrong which lead to this error:
undefined reference to `rte_eth_xstats_get_names'



[dpdk-dev] [PATCH v3 0/3] Keep-alive enhancements

2016-06-15 Thread Remy Horton
This patchset adds enhancements to the keepalive core monitoring and
reporting sub-system. The first is support for idled (sleeping and
frequency-stepped) CPU cores, and the second is support for applications
to be notified of active as well as faulted cores. The latter is to allow
core state to be relayed to external (secondary) processes, which is
demonstrated by changes to the l2fed-keepalive example.

--

v3 changes
* Rebased to master
* Changed keepalive state enumerations to use RTE_ prefix
* Added missing parameter documentation
* Doc changes squashed

v2 changes:
* Some date & typos fixups
* State enum made public and extended with new states
* Generalised 'alive' callback to all states
* Last-alive shows gone-to-sleep time for idle cores
* Removed some redundant sanity checks
* Last-alive time exposed to application
* #define'd semaphore timeout
* Agent checks for dead keepalive

Remy Horton (3):
  eal: export keepalive state enumerations
  eal: add additional keepalive callbacks
  examples/l2fwd-keepalive: add IPC liveness reporting

 doc/guides/rel_notes/release_16_07.rst  |   6 +
 examples/Makefile   |   3 +-
 examples/l2fwd-keepalive/Makefile   |   4 +-
 examples/l2fwd-keepalive/ka-agent/Makefile  |  48 
 examples/l2fwd-keepalive/ka-agent/main.c| 150 
 examples/l2fwd-keepalive/main.c |  22 +++-
 examples/l2fwd-keepalive/shm.c  | 128 
 examples/l2fwd-keepalive/shm.h  |  89 ++
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |   1 +
 lib/librte_eal/common/include/rte_keepalive.h   |  63 +-
 lib/librte_eal/common/rte_keepalive.c   |  64 +++---
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |   1 +
 12 files changed, 558 insertions(+), 21 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h

-- 
2.5.5



[dpdk-dev] [PATCH v3 1/3] eal: export keepalive state enumerations

2016-06-15 Thread Remy Horton
Changes the keepalive state from an anonymous enum to a declared one
which is externally visible, so that keepalive enum values can be
used by applications.

Signed-off-by: Remy Horton 
---
 lib/librte_eal/common/include/rte_keepalive.h | 12 +-
 lib/librte_eal/common/rte_keepalive.c | 34 +++
 2 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/lib/librte_eal/common/include/rte_keepalive.h 
b/lib/librte_eal/common/include/rte_keepalive.h
index 10dac2e..2f856c3 100644
--- a/lib/librte_eal/common/include/rte_keepalive.h
+++ b/lib/librte_eal/common/include/rte_keepalive.h
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright 2015 Intel Shannon Ltd. All rights reserved.
+ *   Copyright 2015-2016 Intel Shannon Ltd. All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
  *   modification, are permitted provided that the following conditions
@@ -48,6 +48,16 @@
 #define RTE_KEEPALIVE_MAXCORES RTE_MAX_LCORE
 #endif

+enum rte_keepalive_state {
+   RTE_UNUSED = 0,
+   RTE_ALIVE = 1,
+   RTE_MISSING = 4,
+   RTE_DEAD = 2,
+   RTE_GONE = 3,
+   RTE_DOZING = 5,
+   RTE_SLEEP = 6
+};
+
 /**
  * Keepalive failure callback.
  *
diff --git a/lib/librte_eal/common/rte_keepalive.c 
b/lib/librte_eal/common/rte_keepalive.c
index 23363ec..dd18e9f 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -42,12 +42,8 @@

 struct rte_keepalive {
/** Core Liveness. */
-   enum rte_keepalive_state {
-   ALIVE = 1,
-   MISSING = 0,
-   DEAD = 2,
-   GONE = 3
-   } __rte_cache_aligned state_flags[RTE_KEEPALIVE_MAXCORES];
+   enum rte_keepalive_state __rte_cache_aligned state_flags[
+   RTE_KEEPALIVE_MAXCORES];

/** Last-seen-alive timestamps */
uint64_t last_alive[RTE_KEEPALIVE_MAXCORES];
@@ -92,16 +88,18 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
continue;

switch (keepcfg->state_flags[idx_core]) {
-   case ALIVE: /* Alive */
-   keepcfg->state_flags[idx_core] = MISSING;
+   case RTE_UNUSED:
+   break;
+   case RTE_ALIVE: /* Alive */
+   keepcfg->state_flags[idx_core] = RTE_MISSING;
keepcfg->last_alive[idx_core] = rte_rdtsc();
break;
-   case MISSING: /* MIA */
+   case RTE_MISSING: /* MIA */
print_trace("Core MIA. ", keepcfg, idx_core);
-   keepcfg->state_flags[idx_core] = DEAD;
+   keepcfg->state_flags[idx_core] = RTE_DEAD;
break;
-   case DEAD: /* Dead */
-   keepcfg->state_flags[idx_core] = GONE;
+   case RTE_DEAD: /* Dead */
+   keepcfg->state_flags[idx_core] = RTE_GONE;
print_trace("Core died. ", keepcfg, idx_core);
if (keepcfg->callback)
keepcfg->callback(
@@ -109,7 +107,13 @@ rte_keepalive_dispatch_pings(__rte_unused void *ptr_timer,
idx_core
);
break;
-   case GONE: /* Buried */
+   case RTE_GONE: /* Buried */
+   break;
+   case RTE_DOZING: /* Core going idle */
+   keepcfg->state_flags[idx_core] = RTE_SLEEP;
+   keepcfg->last_alive[idx_core] = rte_rdtsc();
+   break;
+   case RTE_SLEEP: /* Idled core */
break;
}
}
@@ -137,7 +141,7 @@ void
 rte_keepalive_register_core(struct rte_keepalive *keepcfg, const int id_core)
 {
if (id_core < RTE_KEEPALIVE_MAXCORES) {
-   keepcfg->active_cores[id_core] = 1;
+   keepcfg->active_cores[id_core] = RTE_ALIVE;
keepcfg->last_alive[id_core] = rte_rdtsc();
}
 }
@@ -145,5 +149,5 @@ rte_keepalive_register_core(struct rte_keepalive *keepcfg, 
const int id_core)
 void
 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg)
 {
-   keepcfg->state_flags[rte_lcore_id()] = ALIVE;
+   keepcfg->state_flags[rte_lcore_id()] = RTE_ALIVE;
 }
-- 
2.5.5



[dpdk-dev] [PATCH v3 2/3] eal: add additional keepalive callbacks

2016-06-15 Thread Remy Horton
Adds and documents new callbacks that allow transitions to core
states other than dead to be reported to applications.

Signed-off-by: Remy Horton 
---
 doc/guides/rel_notes/release_16_07.rst  |  6 +++
 examples/Makefile   |  2 +-
 lib/librte_eal/bsdapp/eal/rte_eal_version.map   |  1 +
 lib/librte_eal/common/include/rte_keepalive.h   | 51 +
 lib/librte_eal/common/rte_keepalive.c   | 30 +++
 lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
 6 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/doc/guides/rel_notes/release_16_07.rst 
b/doc/guides/rel_notes/release_16_07.rst
index c0f6b02..df95321 100644
--- a/doc/guides/rel_notes/release_16_07.rst
+++ b/doc/guides/rel_notes/release_16_07.rst
@@ -66,6 +66,12 @@ New Features
   * Enable RSS per network interface through the configuration file.
   * Streamline the CLI code.

+* **Added keepalive enhancements.**
+
+  Adds support for reporting of core states other than dead to
+  monitoring applications, enabling the support of broader liveness
+  reporting to external processes.
+

 Resolved Issues
 ---
diff --git a/examples/Makefile b/examples/Makefile
index b28b30e..3bc635a 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2014 6WIND S.A.
+#   Copyright(c) 2016 6WIND S.A.
 #
 #   Redistribution and use in source and binary forms, with or without
 #   modification, are permitted provided that the following conditions
diff --git a/lib/librte_eal/bsdapp/eal/rte_eal_version.map 
b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
index f8c3dea..0fb1cf2 100644
--- a/lib/librte_eal/bsdapp/eal/rte_eal_version.map
+++ b/lib/librte_eal/bsdapp/eal/rte_eal_version.map
@@ -156,5 +156,6 @@ DPDK_16.07 {
global:

pci_get_sysfs_path;
+   rte_keepalive_register_alive_callback;

 } DPDK_16.04;
diff --git a/lib/librte_eal/common/include/rte_keepalive.h 
b/lib/librte_eal/common/include/rte_keepalive.h
index 2f856c3..e04ea1c 100644
--- a/lib/librte_eal/common/include/rte_keepalive.h
+++ b/lib/librte_eal/common/include/rte_keepalive.h
@@ -63,12 +63,32 @@ enum rte_keepalive_state {
  *
  *  Receives a data pointer passed to rte_keepalive_create() and the id of the
  *  failed core.
+ *  @param data Data pointer passed to rte_keepalive_create()
+ *  @param id_core ID of the core that has failed
  */
 typedef void (*rte_keepalive_failure_callback_t)(
void *data,
const int id_core);

 /**
+ * Keepalive relay callback.
+ *
+ *  Receives a data pointer passed to rte_keepalive_register_relay_callback(),
+ *  the id of the core for which state is to be forwarded, and details of the
+ *  current core state.
+ *  @param data Data pointer passed to rte_keepalive_register_relay_callback()
+ *  @param id_core ID of the core for which state is being reported
+ *  @param core_state The current state of the core
+ *  @param Timestamp of when core was last seen alive
+ */
+typedef void (*rte_keepalive_relay_callback_t)(
+   void *data,
+   const int id_core,
+   enum rte_keepalive_state core_state,
+   uint64_t last_seen
+   );
+
+/**
  * Keepalive state structure.
  * @internal
  */
@@ -115,4 +135,35 @@ void rte_keepalive_register_core(struct rte_keepalive 
*keepcfg,
 void
 rte_keepalive_mark_alive(struct rte_keepalive *keepcfg);

+/**
+ * Per-core sleep-time indication.
+ * @param *keepcfg
+ *   Keepalive structure pointer
+ *
+ * If CPU idling is enabled, this function needs to be called from within
+ * the main process loop of the LCore going to sleep, in order to avoid
+ * the LCore being mis-detected as dead.
+ */
+void
+rte_keepalive_mark_sleep(struct rte_keepalive *keepcfg);
+
+/**
+ * Registers a 'live core' callback.
+ *
+ * The complement of the 'dead core' callback. This is called when a
+ * core is known to be alive, and is intended for cases when an app
+ * needs to know 'liveness' beyond just knowing when a core has died.
+ *
+ * @param *keepcfg
+ *   Keepalive structure pointer
+ * @param callback
+ *   Function called upon detection of a dead core.
+ * @param data
+ *   Data pointer to be passed to function callback.
+ */
+void
+rte_keepalive_register_relay_callback(struct rte_keepalive *keepcfg,
+   rte_keepalive_relay_callback_t callback,
+   void *data);
+
 #endif /* _KEEPALIVE_H_ */
diff --git a/lib/librte_eal/common/rte_keepalive.c 
b/lib/librte_eal/common/rte_keepalive.c
index dd18e9f..0aeee46 100644
--- a/lib/librte_eal/common/rte_keepalive.c
+++ b/lib/librte_eal/common/rte_keepalive.c
@@ -64,6 +64,15 @@ struct rte_keepalive {
void *callback_data;
uint64_t tsc_initial;
uint64_t tsc_mhz;
+
+   /** Core state relay handler. */
+   rte_keepalive_relay_callback_t relay_callback;
+
+   /**
+* Core state relay handler app data.
+* Pointer is passed to live core handler.
+*/
+   void 

[dpdk-dev] [PATCH v3 3/3] examples/l2fwd-keepalive: add IPC liveness reporting

2016-06-15 Thread Remy Horton
Changes the l2fwd keepalive example to show how the new keepalive
enhancements can be used to relay core state to an external process.

Signed-off-by: Remy Horton 
---
 examples/Makefile  |   1 +
 examples/l2fwd-keepalive/Makefile  |   4 +-
 examples/l2fwd-keepalive/ka-agent/Makefile |  48 +
 examples/l2fwd-keepalive/ka-agent/main.c   | 150 +
 examples/l2fwd-keepalive/main.c|  22 -
 examples/l2fwd-keepalive/shm.c | 128 
 examples/l2fwd-keepalive/shm.h |  89 +
 7 files changed, 438 insertions(+), 4 deletions(-)
 create mode 100644 examples/l2fwd-keepalive/ka-agent/Makefile
 create mode 100644 examples/l2fwd-keepalive/ka-agent/main.c
 create mode 100644 examples/l2fwd-keepalive/shm.c
 create mode 100644 examples/l2fwd-keepalive/shm.h

diff --git a/examples/Makefile b/examples/Makefile
index 3bc635a..f650d3e 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -64,6 +64,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_CRYPTODEV) += l2fwd-crypto
 DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += l2fwd-ivshmem
 DIRS-$(CONFIG_RTE_LIBRTE_JOBSTATS) += l2fwd-jobstats
 DIRS-y += l2fwd-keepalive
+DIRS-y += l2fwd-keepalive/ka-agent
 DIRS-$(CONFIG_RTE_LIBRTE_LPM) += l3fwd
 DIRS-$(CONFIG_RTE_LIBRTE_ACL) += l3fwd-acl
 ifeq ($(CONFIG_RTE_LIBRTE_LPM),y)
diff --git a/examples/l2fwd-keepalive/Makefile 
b/examples/l2fwd-keepalive/Makefile
index 568edcb..3fcf513 100644
--- a/examples/l2fwd-keepalive/Makefile
+++ b/examples/l2fwd-keepalive/Makefile
@@ -1,6 +1,6 @@
 #   BSD LICENSE
 #
-#   Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
+#   Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
 #   All rights reserved.
 #
 #   Redistribution and use in source and binary forms, with or without
@@ -42,7 +42,7 @@ include $(RTE_SDK)/mk/rte.vars.mk
 APP = l2fwd-keepalive

 # all source are stored in SRCS-y
-SRCS-y := main.c
+SRCS-y := main.c shm.c

 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
diff --git a/examples/l2fwd-keepalive/ka-agent/Makefile 
b/examples/l2fwd-keepalive/ka-agent/Makefile
new file mode 100644
index 000..f008428
--- /dev/null
+++ b/examples/l2fwd-keepalive/ka-agent/Makefile
@@ -0,0 +1,48 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2016 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+# * 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.
+# * Neither the name of Intel Corporation nor the names of its
+#   contributors may be used to endorse or promote products derived
+#   from this software without specific prior written permission.
+#
+#   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
+#   OWNER 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.
+
+ifeq ($(RTE_SDK),)
+$(error "Please define RTE_SDK environment variable")
+endif
+
+# Default target, can be overridden by command line or environment
+RTE_TARGET ?= x86_64-native-linuxapp-gcc
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+# binary name
+APP = ka-agent
+
+# all source are stored in SRCS-y
+SRCS-y := main.c
+
+CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR)/../
+include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/l2fwd-keepalive/ka-agent/main.c 
b/examples/l2fwd-keepalive/ka-agent/main.c
new file mode 100644
index 000..d1f5e6d
--- /dev/null
+++ b/examples/l2fwd-keepalive/ka-agent/main.c
@@ -0,0 +1,150 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2016 Intel Corporation. All rights reserved.
+ *   All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following 

[dpdk-dev] [PATCH v4 1/8] rte: change xstats to use integer ids

2016-06-15 Thread Thomas Monjalon
2016-06-13 16:51, Remy Horton:
> Signed-off-by: Remy Horton 

Please insert an explanation of why this change is needed.

[...]
>  /**
> + * Retrieve names of extended statistics of an Ethernet device.
> + *
> + * @param port_id
> + *   The port identifier of the Ethernet device.
> + * @param xstats_names
> + *  Block of memory to insert names into. Must be at least size in capacity.
> + *  If set to NULL, function returns required capacity.
> + * @param size
> + *  Capacity of xstats_names (number of names).
> + * @return
> + *  If successful, number of statistics; negative on error.
> + */

Like in rte_eth_xstats_get(), it should return a positive value if size
is not big enough.

> +int rte_eth_xstats_get_names(uint8_t port_id,
> + struct rte_eth_xstat_name *xstats_names,
> + unsigned size);

[...]
> +DPDK_16.07 {
> + global:
> +
> + rte_eth_xstats_names;
> + rte_eth_xstats_count;
> +} DPDK_16.04;

Wrong functions.




[dpdk-dev] [PATCH v3 1/3] eal: export keepalive state enumerations

2016-06-15 Thread Thomas Monjalon
2016-06-15 10:17, Remy Horton:
> +enum rte_keepalive_state {
> + RTE_UNUSED = 0,
> + RTE_ALIVE = 1,
> + RTE_MISSING = 4,
> + RTE_DEAD = 2,
> + RTE_GONE = 3,
> + RTE_DOZING = 5,
> + RTE_SLEEP = 6
> +};

I'm concerned about the namespace here.
RTE_UNUSED and others have a chance to not be unique enough.
Is it possible to have a longer prefix like RTE_KA_ or RTE_STATE_
or RTE_KA_STATE_?


  1   2   3   >