[dpdk-dev] [PATCH v2 9/9] qede: update version to 8.7.9.0_1.1.0.1

2016-06-15 Thread Rasesh Mody
From: Harish Patil 

Signed-off-by: Harish Patil 
---
 drivers/net/qede/qede_ethdev.h |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/qede/qede_ethdev.h b/drivers/net/qede/qede_ethdev.h
index b080f5f..abb33af 100644
--- a/drivers/net/qede/qede_ethdev.h
+++ b/drivers/net/qede/qede_ethdev.h
@@ -40,9 +40,9 @@
 /* Driver versions */
 #define QEDE_PMD_VER_PREFIX"QEDE PMD"
 #define QEDE_PMD_VERSION_MAJOR 1
-#define QEDE_PMD_VERSION_MINOR 0
-#define QEDE_PMD_VERSION_REVISION  6
-#define QEDE_PMD_VERSION_PATCH 1
+#define QEDE_PMD_VERSION_MINOR 1
+#define QEDE_PMD_VERSION_REVISION   0
+#define QEDE_PMD_VERSION_PATCH 1

 #define QEDE_MAJOR_VERSION 8
 #define QEDE_MINOR_VERSION 7
-- 
1.7.10.3



[dpdk-dev] [PATCH v2 8/9] qede: update vport filter settings

2016-06-15 Thread Rasesh Mody
From: Sony Chacko 

Enable promiscuous mode filter settings.
Check for VF mode and enable promiscuous mode settings for VF.
Check filter configuration to ensure conflicting filter modes
are not set.

Signed-off-by: Sony Chacko 
---
 drivers/net/qede/base/ecore_l2.c |   19 +++-
 drivers/net/qede/qede_eth_if.c   |   45 +-
 2 files changed, 39 insertions(+), 25 deletions(-)

diff --git a/drivers/net/qede/base/ecore_l2.c b/drivers/net/qede/base/ecore_l2.c
index 8a1a26a..9e6ef5a 100644
--- a/drivers/net/qede/base/ecore_l2.c
+++ b/drivers/net/qede/base/ecore_l2.c
@@ -227,11 +227,11 @@ ecore_sp_update_accept_mode(struct ecore_hwfn *p_hwfn,
  * SET_FIELD(*state, ETH_VPORT_RX_MODE_UCAST_DROP_ALL,
  *   !!(accept_filter & ECORE_ACCEPT_NONE));
  */
-/*
- * SET_FIELD(*state, ETH_VPORT_RX_MODE_UCAST_ACCEPT_ALL,
- *   (!!(accept_filter & ECORE_ACCEPT_UCAST_MATCHED) &&
- *!!(accept_filter & ECORE_ACCEPT_UCAST_UNMATCHED)));
- */
+
+   SET_FIELD(*state, ETH_VPORT_RX_MODE_UCAST_ACCEPT_ALL,
+ (!!(accept_filter & ECORE_ACCEPT_UCAST_MATCHED) &&
+  !!(accept_filter & ECORE_ACCEPT_UCAST_UNMATCHED)));
+
SET_FIELD(*state, ETH_VPORT_RX_MODE_UCAST_DROP_ALL,
  !(!!(accept_filter & ECORE_ACCEPT_UCAST_MATCHED) ||
!!(accept_filter & ECORE_ACCEPT_UCAST_UNMATCHED)));
@@ -275,6 +275,15 @@ ecore_sp_update_accept_mode(struct ecore_hwfn *p_hwfn,

SET_FIELD(*state, ETH_VPORT_TX_MODE_BCAST_ACCEPT_ALL,
  !!(accept_filter & ECORE_ACCEPT_BCAST));
+   /* @DPDK */
+   /* ETH_VPORT_RX_MODE_UCAST_ACCEPT_ALL and
+* ETH_VPORT_TX_MODE_UCAST_ACCEPT_ALL
+* needs to be set for VF-VF communication to work
+* when dest macaddr is unknown.
+*/
+   SET_FIELD(*state, ETH_VPORT_TX_MODE_UCAST_ACCEPT_ALL,
+ (!!(accept_filter & ECORE_ACCEPT_UCAST_MATCHED) &&
+  !!(accept_filter & ECORE_ACCEPT_UCAST_UNMATCHED)));

DP_VERBOSE(p_hwfn, ECORE_MSG_SP,
   "p_ramrod->tx_mode.state = 0x%x\n",
diff --git a/drivers/net/qede/qede_eth_if.c b/drivers/net/qede/qede_eth_if.c
index fd07d8b..b6f6487 100644
--- a/drivers/net/qede/qede_eth_if.c
+++ b/drivers/net/qede/qede_eth_if.c
@@ -377,33 +377,38 @@ qed_configure_filter_mcast(struct ecore_dev *edev,
return ecore_filter_mcast_cmd(edev, , ECORE_SPQ_MODE_CB, NULL);
 }

-int
-qed_configure_filter_rx_mode(struct ecore_dev *edev,
-enum qed_filter_rx_mode_type type)
+int qed_configure_filter_rx_mode(struct ecore_dev *edev,
+enum qed_filter_rx_mode_type type)
 {
-   struct ecore_filter_accept_flags accept_flags;
+   struct ecore_filter_accept_flags flags;

-   memset(_flags, 0, sizeof(accept_flags));
+   memset(, 0, sizeof(flags));

-   accept_flags.update_rx_mode_config = 1;
-   accept_flags.update_tx_mode_config = 1;
-   accept_flags.rx_accept_filter = ECORE_ACCEPT_UCAST_MATCHED |
-   ECORE_ACCEPT_MCAST_MATCHED |
-   ECORE_ACCEPT_BCAST;
-   accept_flags.tx_accept_filter = ECORE_ACCEPT_UCAST_MATCHED |
+   flags.update_rx_mode_config = 1;
+   flags.update_tx_mode_config = 1;
+   flags.rx_accept_filter = ECORE_ACCEPT_UCAST_MATCHED |
ECORE_ACCEPT_MCAST_MATCHED |
ECORE_ACCEPT_BCAST;

-   if (type == QED_FILTER_RX_MODE_TYPE_PROMISC)
-   accept_flags.rx_accept_filter |= ECORE_ACCEPT_UCAST_UNMATCHED;
-   else if (type == QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC)
-   accept_flags.rx_accept_filter |= ECORE_ACCEPT_MCAST_UNMATCHED;
-   else if (type == (QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC |
- QED_FILTER_RX_MODE_TYPE_PROMISC))
-   accept_flags.rx_accept_filter |= ECORE_ACCEPT_UCAST_UNMATCHED |
-   ECORE_ACCEPT_MCAST_UNMATCHED;
+   flags.tx_accept_filter = ECORE_ACCEPT_UCAST_MATCHED |
+ECORE_ACCEPT_MCAST_MATCHED |
+ECORE_ACCEPT_BCAST;
+
+   if (type == QED_FILTER_RX_MODE_TYPE_PROMISC) {
+   flags.rx_accept_filter |= ECORE_ACCEPT_UCAST_UNMATCHED;
+   if (IS_VF(edev)) {
+   flags.tx_accept_filter |= ECORE_ACCEPT_UCAST_UNMATCHED;
+   DP_INFO(edev, "Enabling Tx unmatched flag for VF\n");
+   }
+   } else if (type == QED_FILTER_RX_MODE_TYPE_MULTI_PROMISC) {
+   flags.rx_accept_filter |= ECORE_ACCEPT_MCAST_UNMATCHED;
+   } else if (type == 

[dpdk-dev] [PATCH v2 7/9] qede: add 100g mode support

2016-06-15 Thread Rasesh Mody
From: Harish Patil 

Change details:
 - Add device id to the PCI table
 - Add polling for the slowpath events for CMT mode device
 - Add prerequisites to allow 100g mode
o Min number of queues needed is 2
o Only even number of queues are allowed
 - Update documentation

Signed-off-by: Harish Patil 
---
 config/common_base |2 +-
 doc/guides/nics/qede.rst   |8 ++---
 drivers/net/qede/qede_ethdev.c |   64 
 drivers/net/qede/qede_ethdev.h |4 ++-
 4 files changed, 72 insertions(+), 6 deletions(-)

diff --git a/config/common_base b/config/common_base
index aeb572e..ee4cf4d 100644
--- a/config/common_base
+++ b/config/common_base
@@ -297,7 +297,7 @@ CONFIG_RTE_LIBRTE_PMD_BOND=y
 CONFIG_RTE_LIBRTE_BOND_DEBUG_ALB=n
 CONFIG_RTE_LIBRTE_BOND_DEBUG_ALB_L1=n

-# QLogic 25G/40G PMD
+# QLogic 25G/40G/100G PMD
 #
 CONFIG_RTE_LIBRTE_QEDE_PMD=n
 CONFIG_RTE_LIBRTE_QEDE_DEBUG_INIT=n
diff --git a/doc/guides/nics/qede.rst b/doc/guides/nics/qede.rst
index c5fbd83..f7ca8eb 100644
--- a/doc/guides/nics/qede.rst
+++ b/doc/guides/nics/qede.rst
@@ -55,7 +55,7 @@ Supported Features
 - TSS
 - Multiple MAC address
 - Default pause flow control
-- SR-IOV VF
+- SR-IOV VF for 25G/40G modes

 Non-supported Features
 --
@@ -70,13 +70,13 @@ Non-supported Features
 Supported QLogic Adapters
 -

-- QLogic FastLinQ QL4 25G/40G CNAs
+- QLogic FastLinQ QL4 25G/40G/100G CNAs.

 Prerequisites
 -

-- Requires firmware version **8.7.x.** and management
-  firmware version **8.7.x or higher**. Firmware may be available
+- Requires firmware version **8.7.x.** and management firmware
+  version **8.7.x or higher**. Firmware may be available
   inbox in certain newer Linux distros under the standard directory
   ``E.g. /lib/firmware/qed/qed_init_values_zipped-8.7.7.0.bin``

diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index c2d030c..d32f7b3 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -7,10 +7,12 @@
  */

 #include "qede_ethdev.h"
+#include 

 /* Globals */
 static const struct qed_eth_ops *qed_ops;
 static const char *drivername = "qede pmd";
+static int64_t timer_period = 1;

 static const struct rte_eth_xstats qede_eth_stats[] = {
{"rx_unicast_bytes", offsetof(struct ecore_eth_stats, rx_ucast_bytes)},
@@ -498,6 +500,21 @@ static int qede_dev_configure(struct rte_eth_dev *eth_dev)
return -EINVAL;
}

+   /* Check requirements for 100G mode */
+   if (edev->num_hwfns > 1) {
+   if (eth_dev->data->nb_rx_queues < 2) {
+   DP_NOTICE(edev, false,
+ "100G mode requires minimum two queues\n");
+   return -EINVAL;
+   }
+
+   if ((eth_dev->data->nb_rx_queues % 2) != 0) {
+   DP_NOTICE(edev, false,
+ "100G mode requires even number of queues\n");
+   return -EINVAL;
+   }
+   }
+
qdev->num_rss = eth_dev->data->nb_rx_queues;

/* Initial state */
@@ -680,6 +697,26 @@ static void qede_promiscuous_disable(struct rte_eth_dev 
*eth_dev)
qede_rx_mode_setting(eth_dev, QED_FILTER_RX_MODE_TYPE_REGULAR);
 }

+static void qede_poll_sp_sb_cb(void *param)
+{
+   struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)param;
+   struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev);
+   struct ecore_dev *edev = QEDE_INIT_EDEV(qdev);
+   int rc;
+
+   qede_interrupt_action(ECORE_LEADING_HWFN(edev));
+   qede_interrupt_action(>hwfns[1]);
+
+   rc = rte_eal_alarm_set(timer_period * US_PER_S,
+  qede_poll_sp_sb_cb,
+  (void *)eth_dev);
+   if (rc != 0) {
+   DP_ERR(edev, "Unable to start periodic"
+" timer rc %d\n", rc);
+   assert(false && "Unable to start periodic timer");
+   }
+}
+
 static void qede_dev_close(struct rte_eth_dev *eth_dev)
 {
struct qede_dev *qdev = eth_dev->data->dev_private;
@@ -712,6 +749,9 @@ static void qede_dev_close(struct rte_eth_dev *eth_dev)
rte_intr_callback_unregister(_dev->pci_dev->intr_handle,
 qede_interrupt_handler, (void *)eth_dev);

+   if (edev->num_hwfns > 1)
+   rte_eal_alarm_cancel(qede_poll_sp_sb_cb, (void *)eth_dev);
+
qdev->state = QEDE_CLOSE;
 }

@@ -1238,9 +1278,26 @@ static int qede_common_dev_init(struct rte_eth_dev 
*eth_dev, bool is_vf)
params.drv_eng = QEDE_ENGINEERING_VERSION;
strncpy((char *)params.name, "qede LAN", QED_DRV_VER_STR_SIZE);

+   /* For CMT mode device do periodic polling for slowpath events.
+* This is required since uio device uses only one MSI-x
+* interrupt vector but 

[dpdk-dev] [PATCH v2 6/9] qede: add support for xstats

2016-06-15 Thread Rasesh Mody
This patch adds support for extended statistics for QEDE PMD.

Signed-off-by: Rasesh Mody 
---
 doc/guides/nics/overview.rst   |2 +-
 drivers/net/qede/qede_ethdev.c |  184 ++--
 2 files changed, 177 insertions(+), 9 deletions(-)

diff --git a/doc/guides/nics/overview.rst b/doc/guides/nics/overview.rst
index bc3faf8..8f48076 100644
--- a/doc/guides/nics/overview.rst
+++ b/doc/guides/nics/overview.rst
@@ -128,7 +128,7 @@ Most of these differences are summarized below.
Packet type parsing  Y Y Y   Y   Y Y Y   Y   Y Y Y Y Y Y
 Y Y
Timesync Y Y Y   Y Y
Basic statsY Y   Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y   
Y Y Y   Y Y Y Y
-   Extended stats Y Y   Y   Y Y Y Y Y Y Y Y Y Y Y Y Y Y
   Y Y
+   Extended stats Y Y   Y   Y Y Y Y Y Y Y Y Y Y Y Y Y Y
 Y Y   Y Y
Stats per queue  Y   Y Y Y Y Y Y Y Y
 Y Y   Y   Y Y
EEPROM dump  Y   Y   Y Y
Registers dump   Y   Y Y Y Y Y Y
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index af16277..c2d030c 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -12,6 +12,146 @@
 static const struct qed_eth_ops *qed_ops;
 static const char *drivername = "qede pmd";

+static const struct rte_eth_xstats qede_eth_stats[] = {
+   {"rx_unicast_bytes", offsetof(struct ecore_eth_stats, rx_ucast_bytes)},
+   {"rx_multicast_bytes",
+   offsetof(struct ecore_eth_stats, rx_mcast_bytes)},
+   {"rx_broadcast_bytes",
+   offsetof(struct ecore_eth_stats, rx_bcast_bytes)},
+   {"rx_unicast_packets", offsetof(struct ecore_eth_stats, rx_ucast_pkts)},
+   {"rx_multicast_packets",
+   offsetof(struct ecore_eth_stats, rx_mcast_pkts)},
+   {"rx_broadcast_packets",
+   offsetof(struct ecore_eth_stats, rx_bcast_pkts)},
+
+   {"tx_unicast_bytes", offsetof(struct ecore_eth_stats, tx_ucast_bytes)},
+   {"tx_multicast_bytes",
+   offsetof(struct ecore_eth_stats, tx_mcast_bytes)},
+   {"tx_broadcast_bytes",
+   offsetof(struct ecore_eth_stats, tx_bcast_bytes)},
+   {"tx_unicast_packets", offsetof(struct ecore_eth_stats, tx_ucast_pkts)},
+   {"tx_multicast_packets",
+   offsetof(struct ecore_eth_stats, tx_mcast_pkts)},
+   {"tx_broadcast_packets",
+   offsetof(struct ecore_eth_stats, tx_bcast_pkts)},
+
+   {"rx_64_byte_packets",
+   offsetof(struct ecore_eth_stats, rx_64_byte_packets)},
+   {"rx_65_to_127_byte_packets",
+   offsetof(struct ecore_eth_stats, rx_65_to_127_byte_packets)},
+   {"rx_128_to_255_byte_packets",
+   offsetof(struct ecore_eth_stats, rx_128_to_255_byte_packets)},
+   {"rx_256_to_511_byte_packets",
+   offsetof(struct ecore_eth_stats, rx_256_to_511_byte_packets)},
+   {"rx_512_to_1023_byte_packets",
+   offsetof(struct ecore_eth_stats, rx_512_to_1023_byte_packets)},
+   {"rx_1024_to_1518_byte_packets",
+   offsetof(struct ecore_eth_stats, rx_1024_to_1518_byte_packets)},
+   {"rx_1519_to_1522_byte_packets",
+   offsetof(struct ecore_eth_stats, rx_1519_to_1522_byte_packets)},
+   {"rx_1519_to_2047_byte_packets",
+   offsetof(struct ecore_eth_stats, rx_1519_to_2047_byte_packets)},
+   {"rx_2048_to_4095_byte_packets",
+   offsetof(struct ecore_eth_stats, rx_2048_to_4095_byte_packets)},
+   {"rx_4096_to_9216_byte_packets",
+   offsetof(struct ecore_eth_stats, rx_4096_to_9216_byte_packets)},
+   {"rx_9217_to_16383_byte_packets",
+   offsetof(struct ecore_eth_stats,
+rx_9217_to_16383_byte_packets)},
+   {"tx_64_byte_packets",
+   offsetof(struct ecore_eth_stats, tx_64_byte_packets)},
+   {"tx_65_to_127_byte_packets",
+   offsetof(struct ecore_eth_stats, tx_65_to_127_byte_packets)},
+   {"tx_128_to_255_byte_packets",
+   offsetof(struct ecore_eth_stats, tx_128_to_255_byte_packets)},
+   {"tx_256_to_511_byte_packets",
+   offsetof(struct ecore_eth_stats, tx_256_to_511_byte_packets)},
+   {"tx_512_to_1023_byte_packets",
+   offsetof(struct ecore_eth_stats, tx_512_to_1023_byte_packets)},
+   {"tx_1024_to_1518_byte_packets",
+   offsetof(struct ecore_eth_stats, tx_1024_to_1518_byte_packets)},
+   {"trx_1519_to_1522_byte_packets",
+   offsetof(struct ecore_eth_stats, tx_1519_to_2047_byte_packets)},
+   {"tx_2048_to_4095_byte_packets",
+   offsetof(struct ecore_eth_stats, tx_2048_to_4095_byte_packets)},
+   {"tx_4096_to_9216_byte_packets",
+   offsetof(struct ecore_eth_stats, 

[dpdk-dev] [PATCH v2 5/9] qede: add support for setting the MTU

2016-06-15 Thread Rasesh Mody
From: Sony Chacko 

Add support for setting the MTU.

Signed-off-by: Sony Chacko 
---
 drivers/net/qede/qede_ethdev.c |   34 ++
 1 file changed, 34 insertions(+)

diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index 3754454..af16277 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -885,6 +885,38 @@ int qede_rss_reta_query(struct rte_eth_dev *eth_dev,
return 0;
 }

+int qede_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
+{
+   uint32_t frame_size;
+   struct qede_dev *qdev = dev->data->dev_private;
+   struct rte_eth_dev_info dev_info = {0};
+
+   qede_dev_info_get(dev, _info);
+
+   /* VLAN_TAG = 4 */
+   frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + 4;
+
+   if ((mtu < ETHER_MIN_MTU) || (frame_size > dev_info.max_rx_pktlen))
+   return -EINVAL;
+
+   if (!dev->data->scattered_rx &&
+   frame_size > dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)
+   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;
+
+   /* update max frame size */
+   dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
+   qdev->mtu = mtu;
+   qede_dev_stop(dev);
+   qede_dev_start(dev);
+
+   return 0;
+}
+
 static const struct eth_dev_ops qede_eth_dev_ops = {
.dev_configure = qede_dev_configure,
.dev_infos_get = qede_dev_info_get,
@@ -916,6 +948,7 @@ static const struct eth_dev_ops qede_eth_dev_ops = {
.rss_hash_conf_get = qede_rss_hash_conf_get,
.reta_update  = qede_rss_reta_update,
.reta_query  = qede_rss_reta_query,
+   .mtu_set = qede_set_mtu,
 };

 static const struct eth_dev_ops qede_eth_vf_dev_ops = {
@@ -944,6 +977,7 @@ static const struct eth_dev_ops qede_eth_vf_dev_ops = {
.rss_hash_conf_get = qede_rss_hash_conf_get,
.reta_update  = qede_rss_reta_update,
.reta_query  = qede_rss_reta_query,
+   .mtu_set = qede_set_mtu,
 };

 static void qede_update_pf_params(struct ecore_dev *edev)
-- 
1.7.10.3



[dpdk-dev] [PATCH v2 4/9] qede: add support for querying rss redirection table

2016-06-15 Thread Rasesh Mody
From: Sony Chacko 

Add support for querying rss redirection table.

Signed-off-by: Sony Chacko 
---
 drivers/net/qede/qede_ethdev.c |   27 +++
 1 file changed, 27 insertions(+)

diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index 2b91e09..3754454 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -860,6 +860,31 @@ int qede_rss_reta_update(struct rte_eth_dev *eth_dev,
return qdev->ops->vport_update(edev, _update_params);
 }

+int qede_rss_reta_query(struct rte_eth_dev *eth_dev,
+   struct rte_eth_rss_reta_entry64 *reta_conf,
+   uint16_t reta_size)
+{
+   struct qede_dev *qdev = eth_dev->data->dev_private;
+   uint16_t i, idx, shift;
+
+   if (reta_size > ETH_RSS_RETA_SIZE_128) {
+   struct ecore_dev *edev = >edev;
+   DP_ERR(edev, "reta_size %d is not supported\n",
+  reta_size);
+   }
+
+   for (i = 0; i < reta_size; i++) {
+   idx = i / RTE_RETA_GROUP_SIZE;
+   shift = i % RTE_RETA_GROUP_SIZE;
+   if (reta_conf[idx].mask & (1ULL << shift)) {
+   uint8_t entry = qdev->rss_params.rss_ind_table[i];
+   reta_conf[idx].reta[shift] = entry;
+   }
+   }
+
+   return 0;
+}
+
 static const struct eth_dev_ops qede_eth_dev_ops = {
.dev_configure = qede_dev_configure,
.dev_infos_get = qede_dev_info_get,
@@ -890,6 +915,7 @@ static const struct eth_dev_ops qede_eth_dev_ops = {
.rss_hash_update = qede_rss_hash_update,
.rss_hash_conf_get = qede_rss_hash_conf_get,
.reta_update  = qede_rss_reta_update,
+   .reta_query  = qede_rss_reta_query,
 };

 static const struct eth_dev_ops qede_eth_vf_dev_ops = {
@@ -917,6 +943,7 @@ static const struct eth_dev_ops qede_eth_vf_dev_ops = {
.rss_hash_update = qede_rss_hash_update,
.rss_hash_conf_get = qede_rss_hash_conf_get,
.reta_update  = qede_rss_reta_update,
+   .reta_query  = qede_rss_reta_query,
 };

 static void qede_update_pf_params(struct ecore_dev *edev)
-- 
1.7.10.3



[dpdk-dev] [PATCH v2 3/9] qede: add support for setting rss redirection table

2016-06-15 Thread Rasesh Mody
From: Sony Chacko 

Add support to configure rss redirection table and update
corresponding documentation.

Signed-off-by: Sony Chacko 
---
 doc/guides/nics/overview.rst   |2 +-
 drivers/net/qede/qede_ethdev.c |   36 
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/overview.rst b/doc/guides/nics/overview.rst
index 2327f5e..bc3faf8 100644
--- a/doc/guides/nics/overview.rst
+++ b/doc/guides/nics/overview.rst
@@ -103,7 +103,7 @@ Most of these differences are summarized below.
Multicast MAC filter   Y Y Y Y Y Y Y Y Y Y Y
 Y Y   Y Y
RSS hash Y   Y Y Y Y Y Y Y   Y Y Y Y Y Y Y Y Y Y
 Y Y
RSS key update   Y   Y Y Y Y Y   Y Y Y Y Y Y Y Y   Y
 Y Y
-   RSS reta update  Y   Y Y Y Y Y   Y Y Y Y Y Y Y Y   Y
+   RSS reta update  Y   Y Y Y Y Y   Y Y Y Y Y Y Y Y   Y
 Y Y
VMDq Y Y Y   Y Y Y Y
SR-IOV   Y   Y   Y Y Y   Y Y Y Y
   Y
DCB  Y Y Y   Y Y
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index 6614632..2b91e09 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -826,6 +826,40 @@ int qede_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
return 0;
 }

+int qede_rss_reta_update(struct rte_eth_dev *eth_dev,
+struct rte_eth_rss_reta_entry64 *reta_conf,
+uint16_t reta_size)
+{
+   struct qed_update_vport_params vport_update_params;
+   struct qede_dev *qdev = eth_dev->data->dev_private;
+   struct ecore_dev *edev = >edev;
+   uint16_t i, idx, shift;
+
+   if (reta_size > ETH_RSS_RETA_SIZE_128) {
+   DP_ERR(edev, "reta_size %d is not supported by hardware\n",
+  reta_size);
+   return -EINVAL;
+   }
+
+   memset(_update_params, 0, sizeof(vport_update_params));
+   memcpy(_update_params.rss_params, >rss_params,
+  sizeof(vport_update_params.rss_params));
+
+   for (i = 0; i < reta_size; i++) {
+   idx = i / RTE_RETA_GROUP_SIZE;
+   shift = i % RTE_RETA_GROUP_SIZE;
+   if (reta_conf[idx].mask & (1ULL << shift)) {
+   uint8_t entry = reta_conf[idx].reta[shift];
+   qdev->rss_params.rss_ind_table[i] = entry;
+   }
+   }
+
+   vport_update_params.update_rss_flg = 1;
+   vport_update_params.vport_id = 0;
+
+   return qdev->ops->vport_update(edev, _update_params);
+}
+
 static const struct eth_dev_ops qede_eth_dev_ops = {
.dev_configure = qede_dev_configure,
.dev_infos_get = qede_dev_info_get,
@@ -855,6 +889,7 @@ static const struct eth_dev_ops qede_eth_dev_ops = {
.dev_supported_ptypes_get = qede_dev_supported_ptypes_get,
.rss_hash_update = qede_rss_hash_update,
.rss_hash_conf_get = qede_rss_hash_conf_get,
+   .reta_update  = qede_rss_reta_update,
 };

 static const struct eth_dev_ops qede_eth_vf_dev_ops = {
@@ -881,6 +916,7 @@ static const struct eth_dev_ops qede_eth_vf_dev_ops = {
.dev_supported_ptypes_get = qede_dev_supported_ptypes_get,
.rss_hash_update = qede_rss_hash_update,
.rss_hash_conf_get = qede_rss_hash_conf_get,
+   .reta_update  = qede_rss_reta_update,
 };

 static void qede_update_pf_params(struct ecore_dev *edev)
-- 
1.7.10.3



[dpdk-dev] [PATCH v2 2/9] qede: add support for getting rss hash configuration

2016-06-15 Thread Rasesh Mody
From: Sony Chacko 

Adding support to get rss hash configuration.

Signed-off-by: Sony Chacko 
---
 drivers/net/qede/qede_ethdev.c |   34 ++
 1 file changed, 34 insertions(+)

diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index 84ff6f8..6614632 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -794,6 +794,38 @@ int qede_rss_hash_update(struct rte_eth_dev *eth_dev,
return qdev->ops->vport_update(edev, _update_params);
 }

+int qede_rss_hash_conf_get(struct rte_eth_dev *eth_dev,
+  struct rte_eth_rss_conf *rss_conf)
+{
+   struct qede_dev *qdev = eth_dev->data->dev_private;
+   uint64_t hf;
+
+   if (rss_conf->rss_key_len < sizeof(qdev->rss_params.rss_key))
+   return -EINVAL;
+
+   if (rss_conf->rss_key)
+   memcpy(rss_conf->rss_key, qdev->rss_params.rss_key,
+  sizeof(qdev->rss_params.rss_key));
+
+   hf = 0;
+   hf |= (qdev->rss_params.rss_caps & ECORE_RSS_IPV4) ?
+   ETH_RSS_IPV4 : 0;
+   hf |= (qdev->rss_params.rss_caps & ECORE_RSS_IPV6) ?
+   ETH_RSS_IPV6 : 0;
+   hf |= (qdev->rss_params.rss_caps & ECORE_RSS_IPV6) ?
+   ETH_RSS_IPV6_EX : 0;
+   hf |= (qdev->rss_params.rss_caps & ECORE_RSS_IPV4_TCP) ?
+   ETH_RSS_NONFRAG_IPV4_TCP : 0;
+   hf |= (qdev->rss_params.rss_caps & ECORE_RSS_IPV6_TCP) ?
+   ETH_RSS_NONFRAG_IPV6_TCP : 0;
+   hf |= (qdev->rss_params.rss_caps & ECORE_RSS_IPV6_TCP) ?
+   ETH_RSS_IPV6_TCP_EX : 0;
+
+   rss_conf->rss_hf = hf;
+
+   return 0;
+}
+
 static const struct eth_dev_ops qede_eth_dev_ops = {
.dev_configure = qede_dev_configure,
.dev_infos_get = qede_dev_info_get,
@@ -822,6 +854,7 @@ static const struct eth_dev_ops qede_eth_dev_ops = {
.flow_ctrl_get = qede_flow_ctrl_get,
.dev_supported_ptypes_get = qede_dev_supported_ptypes_get,
.rss_hash_update = qede_rss_hash_update,
+   .rss_hash_conf_get = qede_rss_hash_conf_get,
 };

 static const struct eth_dev_ops qede_eth_vf_dev_ops = {
@@ -847,6 +880,7 @@ static const struct eth_dev_ops qede_eth_vf_dev_ops = {
.vlan_filter_set = qede_vlan_filter_set,
.dev_supported_ptypes_get = qede_dev_supported_ptypes_get,
.rss_hash_update = qede_rss_hash_update,
+   .rss_hash_conf_get = qede_rss_hash_conf_get,
 };

 static void qede_update_pf_params(struct ecore_dev *edev)
-- 
1.7.10.3



[dpdk-dev] [PATCH v2 1/9] qede: add support for setting hash configuration

2016-06-15 Thread Rasesh Mody
From: Sony Chacko 

Add support for setting hash configuration based on adapter capability
and update corresponding NIC documentation.

Signed-off-by: Sony Chacko 
---
 doc/guides/nics/overview.rst   |2 +-
 doc/guides/nics/qede.rst   |3 +--
 drivers/net/qede/qede_eth_if.h |1 +
 drivers/net/qede/qede_ethdev.c |   43 
 drivers/net/qede/qede_rxtx.c   |   42 +++
 5 files changed, 75 insertions(+), 16 deletions(-)

diff --git a/doc/guides/nics/overview.rst b/doc/guides/nics/overview.rst
index 2200171..2327f5e 100644
--- a/doc/guides/nics/overview.rst
+++ b/doc/guides/nics/overview.rst
@@ -102,7 +102,7 @@ Most of these differences are summarized below.
Unicast MAC filter Y Y Y   Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
 Y Y   Y Y
Multicast MAC filter   Y Y Y Y Y Y Y Y Y Y Y
 Y Y   Y Y
RSS hash Y   Y Y Y Y Y Y Y   Y Y Y Y Y Y Y Y Y Y
 Y Y
-   RSS key update   Y   Y Y Y Y Y   Y Y Y Y Y Y Y Y   Y
+   RSS key update   Y   Y Y Y Y Y   Y Y Y Y Y Y Y Y   Y
 Y Y
RSS reta update  Y   Y Y Y Y Y   Y Y Y Y Y Y Y Y   Y
VMDq Y Y Y   Y Y Y Y
SR-IOV   Y   Y   Y Y Y   Y Y Y Y
   Y
diff --git a/doc/guides/nics/qede.rst b/doc/guides/nics/qede.rst
index 9ff3d1d..c5fbd83 100644
--- a/doc/guides/nics/qede.rst
+++ b/doc/guides/nics/qede.rst
@@ -51,7 +51,7 @@ Supported Features
 - VLAN offload - Filtering and stripping
 - Stateless checksum offloads (IPv4/TCP/UDP)
 - Multiple Rx/Tx queues (queue-pairs)
-- RSS (with default table/key)
+- RSS (with user configurable table/key)
 - TSS
 - Multiple MAC address
 - Default pause flow control
@@ -61,7 +61,6 @@ Non-supported Features
 --

 - Scatter-Gather Rx/Tx frames
-- User configurable RETA table/key
 - Unequal number of Rx/Tx queues
 - MTU change (dynamic)
 - SR-IOV PF
diff --git a/drivers/net/qede/qede_eth_if.h b/drivers/net/qede/qede_eth_if.h
index 61f677c..26968eb 100644
--- a/drivers/net/qede/qede_eth_if.h
+++ b/drivers/net/qede/qede_eth_if.h
@@ -53,6 +53,7 @@ struct qed_dev_eth_info {
 struct qed_update_vport_rss_params {
uint16_t rss_ind_table[128];
uint32_t rss_key[10];
+   u8 rss_caps;
 };

 struct qed_stop_rxq_params {
diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c
index 1273fd3..84ff6f8 100644
--- a/drivers/net/qede/qede_ethdev.c
+++ b/drivers/net/qede/qede_ethdev.c
@@ -753,6 +753,47 @@ qede_dev_supported_ptypes_get(struct rte_eth_dev *eth_dev)
return NULL;
 }

+int qede_rss_hash_update(struct rte_eth_dev *eth_dev,
+struct rte_eth_rss_conf *rss_conf)
+{
+   struct qed_update_vport_params vport_update_params;
+   struct qede_dev *qdev = eth_dev->data->dev_private;
+   struct ecore_dev *edev = >edev;
+   uint8_t rss_caps;
+   uint32_t *key = (uint32_t *)rss_conf->rss_key;
+   uint64_t hf = rss_conf->rss_hf;
+   int i;
+
+   if (hf == 0)
+   DP_ERR(edev, "hash function 0 will disable RSS\n");
+
+   rss_caps = 0;
+   rss_caps |= (hf & ETH_RSS_IPV4)  ? ECORE_RSS_IPV4 : 0;
+   rss_caps |= (hf & ETH_RSS_IPV6)  ? ECORE_RSS_IPV6 : 0;
+   rss_caps |= (hf & ETH_RSS_IPV6_EX)   ? ECORE_RSS_IPV6 : 0;
+   rss_caps |= (hf & ETH_RSS_NONFRAG_IPV4_TCP)  ? ECORE_RSS_IPV4_TCP : 0;
+   rss_caps |= (hf & ETH_RSS_NONFRAG_IPV6_TCP)  ? ECORE_RSS_IPV6_TCP : 0;
+   rss_caps |= (hf & ETH_RSS_IPV6_TCP_EX)   ? ECORE_RSS_IPV6_TCP : 0;
+
+   /* If the mapping doesn't fit any supported, return */
+   if (rss_caps == 0 && hf != 0)
+   return -EINVAL;
+
+   memset(_update_params, 0, sizeof(vport_update_params));
+
+   if (key != NULL)
+   memcpy(qdev->rss_params.rss_key, rss_conf->rss_key,
+  rss_conf->rss_key_len);
+
+   qdev->rss_params.rss_caps = rss_caps;
+   memcpy(_update_params.rss_params, >rss_params,
+  sizeof(vport_update_params.rss_params));
+   vport_update_params.update_rss_flg = 1;
+   vport_update_params.vport_id = 0;
+
+   return qdev->ops->vport_update(edev, _update_params);
+}
+
 static const struct eth_dev_ops qede_eth_dev_ops = {
.dev_configure = qede_dev_configure,
.dev_infos_get = qede_dev_info_get,
@@ -780,6 +821,7 @@ static const struct eth_dev_ops qede_eth_dev_ops = {
.flow_ctrl_set = qede_flow_ctrl_set,
.flow_ctrl_get = qede_flow_ctrl_get,
.dev_supported_ptypes_get = qede_dev_supported_ptypes_get,
+   .rss_hash_update = qede_rss_hash_update,
 };

 static const struct eth_dev_ops qede_eth_vf_dev_ops = {
@@ -804,6 +846,7 @@ static const struct eth_dev_ops qede_eth_vf_dev_ops = {

[dpdk-dev] [PATCH v2 0/9] qede: update qede PMD to 1.1.0.1

2016-06-15 Thread Rasesh Mody
Hi Bruce,

v2 series:
 - made subject and description of the patches verbose where needed.
 - extended stats patch: some of the stats may sound similar, however,
   they are different stats collected by different hw componenets
   (eg. mac, rx pipeline, etc). We've tried our best to elaborate each
   stat as applicable and provided a direction. All other comments on
   the patch addressed.

This patch set adds support for enabling 100G mode for QEDE PMD.
It also adds support for APIs like
 - mtu_set
 - reta_update
 - reta_query
 - rss_hash_update
 - rss_hash_conf_get
 - xstats_get
The changes include enablement of vf-vf traffic and updated the driver
version to 8.7.9.0_1.1.0.1

The patches have been generated and tested against dpdk-next-net rel_16_07
branch.

Please apply!

Harish Patil (2):
  qede: add 100g mode support
  qede: update version to 8.7.9.0_1.1.0.1

Rasesh Mody (1):
  qede: add support for xstats

Sony Chacko (6):
  qede: add support for setting hash configuration
  qede: add support for getting rss hash configuration
  qede: add support for setting rss redirection table
  qede: add support for querying rss redirection table
  qede: add support for setting the MTU
  qede: update vport filter settings

 config/common_base   |2 +-
 doc/guides/nics/overview.rst |6 +-
 doc/guides/nics/qede.rst |   11 +-
 drivers/net/qede/base/ecore_l2.c |   19 +-
 drivers/net/qede/qede_eth_if.c   |   45 ++--
 drivers/net/qede/qede_eth_if.h   |1 +
 drivers/net/qede/qede_ethdev.c   |  422 +-
 drivers/net/qede/qede_ethdev.h   |   10 +-
 drivers/net/qede/qede_rxtx.c |   42 ++--
 9 files changed, 498 insertions(+), 60 deletions(-)

-- 
1.7.10.3



[dpdk-dev] [PATCH v2] rte_hash: add scalable multi-writer insertion w/ Intel TSX

2016-06-15 Thread Wei Shen
This patch introduced scalable multi-writer Cuckoo Hash insertion
based on a split Cuckoo Search and Move operation using Intel
TSX. It can do scalable hash insertion with 22 cores with little
performance loss and negligible TSX abortion rate.

* Added an extra rte_hash flag definition to switch default
  single writer Cuckoo Hash behavior to multiwriter.

* Added a make_space_insert_bfs_mw() function to do split Cuckoo
  search in BFS order.

* Added tsx_cuckoo_move_insert() to do Cuckoo move in Intel TSX
  protected manner.

* Added test_hash_multiwriter() as test case for multi-writer
  Cuckoo Hash.

Signed-off-by: Shen Wei 
Signed-off-by: Sameh Gobriel 
---
 app/test/Makefile  |   1 +
 app/test/test_hash_multiwriter.c   | 272 +
 doc/guides/rel_notes/release_16_07.rst |  12 ++
 lib/librte_hash/rte_cuckoo_hash.c  | 231 +---
 lib/librte_hash/rte_hash.h |   3 +
 5 files changed, 494 insertions(+), 25 deletions(-)
 create mode 100644 app/test/test_hash_multiwriter.c

diff --git a/app/test/Makefile b/app/test/Makefile
index 053f3a2..5476300 100644
--- a/app/test/Makefile
+++ b/app/test/Makefile
@@ -120,6 +120,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_thash.c
 SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_perf.c
 SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_functions.c
 SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_scaling.c
+SRCS-$(CONFIG_RTE_LIBRTE_HASH) += test_hash_multiwriter.c

 SRCS-$(CONFIG_RTE_LIBRTE_LPM) += test_lpm.c
 SRCS-$(CONFIG_RTE_LIBRTE_LPM) += test_lpm_perf.c
diff --git a/app/test/test_hash_multiwriter.c b/app/test/test_hash_multiwriter.c
new file mode 100644
index 000..54a0d2c
--- /dev/null
+++ b/app/test/test_hash_multiwriter.c
@@ -0,0 +1,272 @@
+/*-
+ *   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.
+ */
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test.h"
+
+/*
+ * Check condition and return an error if true. Assumes that "handle" is the
+ * name of the hash structure pointer to be freed.
+ */
+#define RETURN_IF_ERROR(cond, str, ...) do {\
+   if (cond) { \
+   printf("ERROR line %d: " str "\n", __LINE__,\
+   ##__VA_ARGS__); \
+   if (handle) \
+   rte_hash_free(handle);  \
+   return -1;  \
+   }   \
+} while (0)
+
+#define RTE_APP_TEST_HASH_MULTIWRITER_FAILED 0
+
+struct {
+   uint32_t *keys;
+   uint32_t *found;
+   uint32_t nb_tsx_insertion;
+   struct rte_hash *h;
+} tbl_multiwriter_test_params;
+
+const uint32_t nb_entries = 16*1024*1024;
+const uint32_t nb_total_tsx_insertion = 15*1024*1024;
+uint32_t rounded_nb_total_tsx_insertion;
+
+static rte_atomic64_t gcycles;
+static rte_atomic64_t ginsertions;
+
+static int
+test_hash_multiwriter_worker(__attribute__((unused)) void *arg)
+{
+   uint64_t i, offset;
+   uint32_t lcore_id = rte_lcore_id();
+   uint64_t begin, cycles;
+
+   offset = 

[dpdk-dev] [PATCH] dropping librte_ivshmem

2016-06-15 Thread Thomas Monjalon
2016-06-15 19:16, Ferruh Yigit:
> On 6/9/2016 10:26 PM, Thomas Monjalon wrote:
> > So this is my proposal:
> > Someone start working on the above cleanup now, otherwise the whole
> > rte_ivshmem feature will be deprecated in 16.07 and removed in 16.11.
> 
> I would like to note that at least SPP (soft patch panel) is using
> rte_ivshmem feature.

Why?
Can SPP work without ivshmem?


[dpdk-dev] [PATCH] mk: define objcopy target and arch on IBM POWER

2016-06-15 Thread Chao Zhu
This patch defines the target and arch value of objcopy program for
IBM POWER PPC64 little endian architecture. This is a fix of the
original patch proposed by Jan Viktorin .

Signed-off-by: Chao Zhu 
---
 mk/arch/ppc_64/rte.vars.mk |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/mk/arch/ppc_64/rte.vars.mk b/mk/arch/ppc_64/rte.vars.mk
index 363fcd1..ef3ba1d 100644
--- a/mk/arch/ppc_64/rte.vars.mk
+++ b/mk/arch/ppc_64/rte.vars.mk
@@ -37,3 +37,8 @@ CPU_LDFLAGS ?=
 CPU_ASFLAGS ?= -felf64

 export ARCH CROSS CPU_CFLAGS CPU_LDFLAGS CPU_ASFLAGS
+
+RTE_OBJCOPY_TARGET = elf64-powerpcle
+RTE_OBJCOPY_ARCH = powerpc:common64
+
+export RTE_OBJCOPY_TARGET RTE_OBJCOPY_ARCH
-- 
1.7.1



[dpdk-dev] [PATCH] dropping librte_ivshmem - was log: deprecate history dump

2016-06-15 Thread Ferruh Yigit
On 6/9/2016 10:26 PM, Thomas Monjalon wrote:
> Looking a bit more into librte_ivshmem, the documentation says we need
> a Qemu patch but the URL doesn't exist anymore:
>   https://01.org/packet-processing/intel%C2%AE-ovdk
>   -> 404 Oops, we couldn't find that page
> 
> I've never understood why we should keep this wart and now I'm going
> to be upset.
> To sum up the situation, eal depends on ivshmem which depends on
> ring/mempool which depends... on eal.
> The truth is that eal should not depends on librte_ivshmem.
> And the option CONFIG_RTE_LIBRTE_IVSHMEM should not exist.
> 
> There are 3 parts to distinguish:
> 
> 1/ The librte_ivshmem API to export some data structures from host.
> No real problem here.
> 
> 2/ The scan of the ivshmem devices in the guest init.
> It should be handled as any other PCI device with an appropriate driver.
> The scan is done by rte_eal_pci_init.
> 
> 3/ The automatic mapped allocation of DPDK objects in the guest.
> It should not be done in EAL.
> An ivshmem driver would be called by rte_eal_dev_init.
> It would check where are the shared DPDK structures, as currently done
> with the IVSHMEM_MAGIC (0x0BADC0DE), and do the appropriate allocations.
> Thus only the driver would depend on ring and mempool.
> 
> The last step of the ivshmem cleanup will be to remove the memory hack
> RTE_EAL_SINGLE_FILE_SEGMENTS. Then CONFIG_RTE_LIBRTE_IVSHMEM could be
> removed.
> 
> So this is my proposal:
> Someone start working on the above cleanup now, otherwise the whole
> rte_ivshmem feature will be deprecated in 16.07 and removed in 16.11.

I would like to note that at least SPP (soft patch panel) is using
rte_ivshmem feature.

> We already talked about the rte_ivshmem design issues several times
> and nobody declared using it.
> 



[dpdk-dev] [PATCH v2 0/7] virtio-net support on ppc64

2016-06-15 Thread Thomas Monjalon
> David Marchand (1):
>   virtio: fix pci accesses for ppc64 in legacy mode
> 
> Olivier Matz (6):
>   eal: fix typos in ioport API doxygen comments
>   eal/linux: only call iopl on x86
>   eal/linux: remove invalid comment
>   eal/linux: split function parsing pci resources in sysfs
>   eal/linux: mmap ioports on ppc64
>   config: enable virtio-net pmd for ppc64

Rebased on top of "pci: allow to override sysfs path" and
Applied, thanks


[dpdk-dev] random pkt generator PMD

2016-06-15 Thread Yerden Zhumabekov


On 15.06.2016 18:25, Dumitrescu, Cristian wrote:

 So add a loop-mode to pcap pmd?
>>> It would be nice to have an option like "...,rewind=1,...".
>> As Cristian points out in
>> http://dpdk.org/ml/archives/dev/2016-June/041589.html, the current pmd
>> behavior of stopping is the odd man out in the pmd crowd.
>>
>> Rather than whether to rewind or not, I'd make the number of loops
>> configurable, defaulting to forever and 1 being the equal to current
>> behavior.
>>
>>  - Panu -
> +1

I'm afraid, all packets from pcap file would need to be preloaded to 
memory. Otherwise, each loop would infer pcap_open/pcap_close(), am I wrong?


[dpdk-dev] random pkt generator PMD

2016-06-15 Thread Yerden Zhumabekov

On 15.06.2016 18:33, Jay Rolette wrote:
> On Wed, Jun 15, 2016 at 7:11 AM, Yerden Zhumabekov 
> wrote:
>>
>> On 15.06.2016 17:50, Jay Rolette wrote:
>>
>>> On Wed, Jun 15, 2016 at 4:43 AM, Yerden Zhumabekov 
>>> wrote:
>>>
>>> Hello everybody,
 DPDK already got a number of PMDs for various eth devices, it even has
 PMD
 emulations for backends such as pcap, sw rings etc.

 I've been thinking about the idea of having PMD which would generate
 mbufs
 on the fly in some randomized fashion. This would serve goals like, for
 example:

 1) running tests for applications with network processing capabilities
 without additional software packet generators;
 2) making performance measurements with no hw inteference;
 3) ability to run without root privileges, --no-pci, --no-huge, for CI
 build, so on.

 Maybe there's no such need, and these goals may be achieved by other
 means
 and this idea is flawed? Any thoughts?

 Are you thinking of something along the lines of what BreakingPoint (now
>>> part of Ixia) does, but as an open source software tool?
>>>
>>>
>> More dreaming than thinking though :) Live flows generation, malware,
>> attacks simulation etc is way out of scope of PMD dev, I guess.
>>
> Having a DPDK-based open-source BreakingPoint app would be a _fantastic_
> tool for the security community, but yes, it doesn't really make sense to
> put any of that logic in the PMD itself.
>
> Were you more after the capabilities from that sort of tool or the
> experience of writing a PMD?
>

We're developing packet processing applications for our company and, of 
course, having a testing tool with such capabilities would be great. As 
for experience in PMD development - sure, why not getting it.


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

2016-06-15 Thread Olivier MATZ


On 06/15/2016 06:34 PM, Hunt, David wrote:
>
>
> On 15/6/2016 1:03 PM, Olivier MATZ wrote:
>> [...]
>>
>> The opaque pointer would be saved in mempool structure, and used
>> when the mempool is populated (calling mempool_ops_alloc).
>> The type of the structure pointed by the opaque has to be defined
>> (and documented) into each mempool_ops manager.
>>
>>
>> Olivier
>
>
> OK, just to be sure before I post another patchset.
>
> For the rte_mempool_struct:
>  struct rte_mempool_memhdr_list mem_list; /**< List of memory
> chunks */
> +   void *ops_args;  /**< optional args for ops
> alloc. */
>
> (at the end of the struct, as it's just on the control path, not to
> affect fast path)

Hmm, I would put it just after pool_data.


>
> Then change function params:
>   int
> -rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name);
> +rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
> +   void *ops_args);
>
> And (almost) finally in the rte_mempool_set_ops_byname function:
>  mp->ops_index = i;
> +   mp->ops_args = ops_args;
>  return 0;
>
> Then (actually) finally, add a null to all the calls to
> rte_mempool_set_ops_byname.
>
> OK? :)
>

Else, looks good to me! Thanks David.



[dpdk-dev] random pkt generator PMD

2016-06-15 Thread Yerden Zhumabekov


On 15.06.2016 17:25, Panu Matilainen wrote:
> On 06/15/2016 02:10 PM, Yerden Zhumabekov wrote:
>>
>>
>> On 15.06.2016 16:43, Dumitrescu, Cristian wrote:
>>>

 Hello everybody,

 DPDK already got a number of PMDs for various eth devices, it even has
 PMD emulations for backends such as pcap, sw rings etc.

 I've been thinking about the idea of having PMD which would generate
 mbufs on the fly in some randomized fashion. This would serve goals
 like, for example:

 1) running tests for applications with network processing capabilities
 without additional software packet generators;
 2) making performance measurements with no hw inteference;
 3) ability to run without root privileges, --no-pci, --no-huge, for CI
 build, so on.

 Maybe there's no such need, and these goals may be achieved by other
 means and this idea is flawed? Any thoughts?
>>> How about a Perl/Python script to generate a PCAP file with random
>>> packets and then feed the PCAP file to the PCAP PMD?
>>>
>>> Random can mean different requirements for different
>>> users/application, I think it is difficult to fit this  under a simple
>>> generic API. Customizing the script for different requirements if a
>>> far better option in my opinion.
>>
>> AFAIK, the thing about pcap pmd is that one needs to rewind pcap file
>> once pcap pmd reaches its end. It requires additional (non-generic)
>> handling in app code.
>
> So add a loop-mode to pcap pmd?

It would be nice to have an option like "...,rewind=1,...".


[dpdk-dev] [PATCH v2 5/7] eal/linux: mmap ioports on ppc64

2016-06-15 Thread Thomas Monjalon
2016-05-30 10:45, Olivier Matz:
> On 05/24/2016 07:15 AM, Yuanhan Liu wrote:
> > On Mon, May 23, 2016 at 03:40:58PM +0200, Olivier Matz wrote:
> >> For reference, here is the report of the ABI checker for EAL:
> >>
> >> [?] struct rte_pci_ioport (2)
> >>
> >>  1 Field len has been added to this type.
> >>1) This field will not be initialized by old clients.
> >>2) Size of the inclusive type has been changed.
> >>   NOTE: this field should be accessed only from the new library
> >>   functions, otherwise it may result in crash or incorrect behavior
> >>   of applications.
> >>  2 Size of this type has been changed from 16 bytes to 24 bytes.   
> >>The fields or parameters of such data type may be incorrectly
> >>initialized or accessed by old client applications.
> >>
> >> [?] affected symbols (4)
> >>  rte_eal_pci_ioport_map ( struct rte_pci_device* dev, int bar,
> >> struct rte_pci_ioport* p ) @@ DPDK_16.04
> >>  3rd parameter 'p' (pointer) has base type 'struct rte_pci_ioport'.
> >>  rte_eal_pci_ioport_read ( struct rte_pci_ioport* p, void* data,
> >> size_t len, off_t offset ) @@ DPDK_16.04
> >>  1st parameter 'p' (pointer) has base type 'struct rte_pci_ioport'.
> >>  rte_eal_pci_ioport_unmap ( struct rte_pci_ioport* p ) @@ DPDK_16.04
> >>  1st parameter 'p' (pointer) has base type 'struct rte_pci_ioport'.
> >>  rte_eal_pci_ioport_write ( struct rte_pci_ioport* p, void const* data,
> >> size_t len, off_t offset ) @@ DPDK_16.04
> >>  1st parameter 'p' (pointer) has base type 'struct rte_pci_ioport'.
> >>
> >>
> >> My understanding of the comment for this structure is that it's
> >> internal to EAL:
> > 
> > I'm not quite sure that is enough. Cc'ed Panu, the guru on ABI stuff,
> > hopefully he could shed some light on it.
> > 
> >> /**
> >>  * A structure used to access io resources for a pci device.
> >>  * rte_pci_ioport is arch, os, driver specific, and should not be used
> >> outside
> >>  * of pci ioport api.
> >>  */
> >> struct rte_pci_ioport {
> >>  ...
> >> }
> >>
> >> So I'd say it's ok to have it integrated for 16.07.
> > 
> > I'll let Thomas to decide it :)
> 
> Panu or Thomas, do you have any comment on this?

The user of this struct is virtio.
The ABI policy does not apply to drivers:
- A means Application
- external drivers must be rebuilt for each new release

Thus no problem here.


[dpdk-dev] random pkt generator PMD

2016-06-15 Thread Yerden Zhumabekov


On 15.06.2016 17:50, Jay Rolette wrote:
> On Wed, Jun 15, 2016 at 4:43 AM, Yerden Zhumabekov 
> wrote:
>
>> Hello everybody,
>>
>> DPDK already got a number of PMDs for various eth devices, it even has PMD
>> emulations for backends such as pcap, sw rings etc.
>>
>> I've been thinking about the idea of having PMD which would generate mbufs
>> on the fly in some randomized fashion. This would serve goals like, for
>> example:
>>
>> 1) running tests for applications with network processing capabilities
>> without additional software packet generators;
>> 2) making performance measurements with no hw inteference;
>> 3) ability to run without root privileges, --no-pci, --no-huge, for CI
>> build, so on.
>>
>> Maybe there's no such need, and these goals may be achieved by other means
>> and this idea is flawed? Any thoughts?
>>
> Are you thinking of something along the lines of what BreakingPoint (now
> part of Ixia) does, but as an open source software tool?
>

More dreaming than thinking though :) Live flows generation, malware, 
attacks simulation etc is way out of scope of PMD dev, I guess.


[dpdk-dev] [PATCH v9 0/6] virtio support for container

2016-06-15 Thread Yuanhan Liu
Applied to dpdk-next-virtio.

Thanks.

--yliu


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

2016-06-15 Thread Yuanhan Liu
Applied to dpdk-next-virtio, with following small changes, for
addressing a build error and some checkpatch warnings.

Thanks.

--yliu

---
diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 026b8a1..ea7a48e 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -307,9 +307,9 @@ int virtio_dev_queue_setup(struct rte_eth_dev *dev,
const struct rte_memzone *mz = NULL, *hdr_mz = NULL;
unsigned int vq_size, size;
struct virtio_hw *hw = dev->data->dev_private;
-   struct virtnet_rx *rxvq;
-   struct virtnet_tx *txvq;
-   struct virtnet_ctl *cvq;
+   struct virtnet_rx *rxvq = NULL;
+   struct virtnet_tx *txvq = NULL;
+   struct virtnet_ctl *cvq = NULL;
struct virtqueue *vq;
const char *queue_names[] = {"rvq", "txq", "cvq"};
size_t sz_vq, sz_q = 0, sz_hdr_mz = 0;
diff --git a/drivers/net/virtio/virtio_user/vhost.h 
b/drivers/net/virtio/virtio_user/vhost.h
index 8d1e505..897042f 100644
--- a/drivers/net/virtio/virtio_user/vhost.h
+++ b/drivers/net/virtio/virtio_user/vhost.h
@@ -141,6 +141,6 @@ struct vhost_user_msg {

 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);
+int vhost_user_enable_queue_pair(int vhostfd, uint16_t 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 98d98b6..95e80f8 100644
--- a/drivers/net/virtio/virtio_user/vhost_user.c
+++ b/drivers/net/virtio/virtio_user/vhost_user.c
@@ -100,8 +100,9 @@ vhost_user_read(int fd, struct vhost_user_msg *msg)
if (sz_payload) {
ret = recv(fd, (void *)((char *)msg + sz_hdr), sz_payload, 0);
if (ret < sz_payload) {
-   PMD_DRV_LOG(ERR, "Failed to recv msg payload: %d 
instead of %d.",
-   ret, msg->size);
+   PMD_DRV_LOG(ERR,
+   "Failed to recv msg payload: %d instead of %d.",
+   ret, msg->size);
goto fail;
}
}
@@ -406,7 +407,7 @@ vhost_user_setup(const char *path)
 }

 int
-vhost_user_enable_queue_pair(int vhostfd, unsigned pair_idx, int enable)
+vhost_user_enable_queue_pair(int vhostfd, uint16_t pair_idx, int enable)
 {
int i;

@@ -422,5 +423,4 @@ vhost_user_enable_queue_pair(int vhostfd, unsigned 
pair_idx, int enable)
}

return 0;
-
 }
diff --git a/drivers/net/virtio/virtio_user_ethdev.c 
b/drivers/net/virtio/virtio_user_ethdev.c
index 4c9279e..9216182 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -46,7 +46,7 @@
 #include "virtio_user/virtio_user_dev.h"

 #define virtio_user_get_dev(hw) \
-   ((struct virtio_user_dev *)(hw)->virtio_user_dev);
+   ((struct virtio_user_dev *)(hw)->virtio_user_dev)

 static void
 virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset,


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

2016-06-15 Thread Hunt, David


On 15/6/2016 1:03 PM, Olivier MATZ wrote:
> [...]
>
> The opaque pointer would be saved in mempool structure, and used
> when the mempool is populated (calling mempool_ops_alloc).
> The type of the structure pointed by the opaque has to be defined
> (and documented) into each mempool_ops manager.
>
>
> Olivier


OK, just to be sure before I post another patchset.

For the rte_mempool_struct:
 struct rte_mempool_memhdr_list mem_list; /**< List of memory 
chunks */
+   void *ops_args;  /**< optional args for ops 
alloc. */

(at the end of the struct, as it's just on the control path, not to 
affect fast path)

Then change function params:
  int
-rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name);
+rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
+   void *ops_args);

And (almost) finally in the rte_mempool_set_ops_byname function:
 mp->ops_index = i;
+   mp->ops_args = ops_args;
 return 0;

Then (actually) finally, add a null to all the calls to 
rte_mempool_set_ops_byname.

OK? :)

Regards,
Dave.








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

2016-06-15 Thread Ivan Boule
On 06/15/2016 04:27 PM, Ananyev, Konstantin wrote:
>
>
>> -Original Message-
>> From: Richardson, Bruce
>> Sent: Wednesday, June 15, 2016 3:22 PM
>> To: Ananyev, Konstantin
>> Cc: Ivan Boule; Thomas Monjalon; Pattan, Reshma; dev at dpdk.org
>> Subject: Re: [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx 
>> callback lists
>>
>> On Wed, Jun 15, 2016 at 03:20:27PM +0100, Ananyev, Konstantin wrote:
>>>
>>>
 -Original Message-
 From: Ivan Boule [mailto:ivan.boule at 6wind.com]
 Sent: Wednesday, June 15, 2016 3:07 PM
 To: Richardson, Bruce; Ananyev, Konstantin
 Cc: Thomas Monjalon; Pattan, Reshma; dev at dpdk.org
 Subject: Re: [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx 
 callback lists

 On 06/15/2016 03:29 PM, Bruce Richardson wrote:
> On Wed, Jun 15, 2016 at 12:40:16PM +, Ananyev, Konstantin wrote:
>> Hi Ivan,
>>
>>> -Original Message-
>>> From: Ivan Boule [mailto:ivan.boule at 6wind.com]
>>> Sent: Wednesday, June 15, 2016 1:15 PM
>>> To: Thomas Monjalon; Ananyev, Konstantin
>>> Cc: Pattan, Reshma; dev at dpdk.org
>>> Subject: Re: [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect 
>>> Rx/Tx callback lists
>>>
>>> On 06/15/2016 10:48 AM, Thomas Monjalon wrote:
>>>
>
>> 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.

>>>
>>> Hi Reshma,
>>>
>>> You claim that the "rte_eth_rx_cb_lock" does not need to be hold in the
>>> function "rte_eth_rx_burst()" while parsing the "post_rx_burst_cbs" list
>>> of RX callbacks associated with the polled RX queue to safely remove RX
>>> callback(s) in parallel.
>>> The problem is not [only] with the setting and the loading of "cb->next"
>>> that you assume to be atomic operations, which is certainly true on most
>>> CPUs.
>>> I see the 2 important following issues:
>>>
>>> 1) the "rte_eth_rxtx_callback" data structure associated with a removed
>>> RX callback could still be accessed in the callback parsing loop of the
>>> function "rte_eth_rx_burst()" after having been freed in parallel.
>>>
>>> BUT SUCH A BAD SITUATION WILL NOT CURRENTLY HAPPEN, THANKS TO THE NICE
>>> MEMORY LEAK BUG in the function "rte_eth_remove_rx_callback()"  that
>>> does not free the "rte_eth_rxtx_callback" data structure associated with
>>> the removed callback !
>>
>> Yes, though it is documented behaviour, someone can probably
>> refer it as a feature, not a bug ;)
>>
>
> +1
> This is definitely not a bug, this is absolutely by design. One may argue 
> with
> the design, but it was done for a definite reason, so as to avoid paying 
> the
> penalty of having locks. It pushes more responsibility onto the app, but 
> it
> does allow the app to choose the best solution for managing the freeing of
> memory for its situation. The alternative is to force all apps to pay the 
> cost
> of having locks, even if better options for freeing the memory are 
> available.
>
> /Bruce
>

 -1 (not to say 0x)

 This is definitely an API design bug !
 I would say that if you don't know how to free a resource that you
 allocate, it is very likely that you are wrong allocating it.
 And this is exactly what happens here with RX/TX callback data structures.
 This problem can easily be addressed by just changing the API as follows:

 Change
   void *
   rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
   rte_rx_callback_fn fn, void *user_param)

 to
   int
   rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
   struct rte_eth_rxtx_callback *cb)

 In addition of solving the problem, this approach makes the API
 consistent and let the application allocate "rte_eth_rxtx_callback" data
 structures through any appropriate mean.
>>>
>>> That might make API a bit cleaner, but I don't see how it fixes the generic 
>>> problem:
>>> there is still no way to know by the upper layer when it is safe to 
>>> free/re-use
>>> removed callback, but to make sure that all IO on that queue is stopped
>>> (I.E. some 

[dpdk-dev] [PATCH v5 02/38] bnxt: add HWRM init code

2016-06-15 Thread Ferruh Yigit
On 6/14/2016 11:55 PM, Stephen Hurd wrote:
> From: Ajit Khaparde 
> 
> Start adding support to use the HWRM API.
> Hardware Resource Manager or HWRM in short, is a set of API provided
> by the firmware running in the ASIC to manage the various resources.
> 
> Initial commit just performs necessary HWRM queries for init, then
> fails as before.
> 
> Now that struct bnxt is non-zero size, we can set dev_private_size
> correctly.
> 
> The used HWRM calls so far:
> bnxt_hwrm_func_qcaps:
>   This command returns capabilities of a function.
> 
> bnxt_hwrm_ver_get:
>   This function is called by a driver to determine the HWRM
>   interface version supported by the HWRM firmware, the
>   version of HWRM firmware implementation, the name of HWRM
>   firmware, the versions of other embedded firmwares, and
>   the names of other embedded firmwares, etc.  Gets the
>   firmware version and interface specifications.  Returns
>   an error if the firmware on the device is not supported
>   by the driver and ensures the response space is large
>   enough for the largest possible response.
> 
> bnxt_hwrm_queue_qportcfg:
>   This function is called by a driver to query queue
>   configuration of a port.
> 
> Signed-off-by: Ajit Khaparde 
> Signed-off-by: Stephen Hurd 
> Reviewed-by: David Christensen 
> 
> --
> v4:
> Fix few issues highlighted by checkpatch.
> 
> v5:
> Fix footer formatting
> Switch to using the HWRM function descriptions from the source
> documentation
> ---

Hi Stephen,

I run basic checks on the patch set, mainly it compiles and applies
fine, overall patch set looks good.

Only get following checkpatch warning:
Only v5,02/38 has one WARNING:MACRO_WITH_FLOW_CONTROL

And my script caught following typos on commit messages:
v5-07-38: mamagement
v5-12-38: staitstics, asociated
v5-14-38: fo
v5-25-38: cleansup
v5-28-38: arugments
v5-30-38: wraper

If there won't be a new version of patch set, perhaps we can ask Bruce
to fix typos when applying J

Thanks,
ferruh




[dpdk-dev] [PATCH v3] mbuf: new flag when Vlan is stripped

2016-06-15 Thread Thomas Monjalon
2016-06-15 12:33, Ananyev, Konstantin:
> From: Olivier Matz [mailto:olivier.matz at 6wind.com]
> > The behavior of PKT_RX_VLAN_PKT was not very well defined, resulting in
> > PMDs not advertising the same flags in similar conditions.
> > 
> > Following discussion in [1], introduce 2 new flags PKT_RX_VLAN_STRIPPED
> > and PKT_RX_QINQ_STRIPPED that are better defined:
> > 
> >   PKT_RX_VLAN_STRIPPED: a vlan has been stripped by the hardware and its
> >   tci is saved in mbuf->vlan_tci. This can only happen if vlan stripping
> >   is enabled in the RX configuration of the PMD.
> > 
> > For now, the old flag PKT_RX_VLAN_PKT is kept but marked as deprecated.
> > It should be removed from applications and PMDs in a future revision.
[...]
> > For PKT_RX_QINQ_PKT, it was only supported on i40e, and the behavior was
> > already correct, so we can reuse the same bit value for
> > PKT_RX_QINQ_STRIPPED.
> > 
> > [1] http://dpdk.org/ml/archives/dev/2016-April/037837.html,
> > 
> > Signed-off-by: Olivier Matz 
> 
> Acked-by: Konstantin Ananyev 

Applied, thanks



[dpdk-dev] random pkt generator PMD

2016-06-15 Thread Yerden Zhumabekov


On 15.06.2016 16:43, Dumitrescu, Cristian wrote:
>
>> -Original Message-
>> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Yerden
>> Zhumabekov
>> Sent: Wednesday, June 15, 2016 10:44 AM
>> To: dev at dpdk.org
>> Subject: [dpdk-dev] random pkt generator PMD
>>
>> Hello everybody,
>>
>> DPDK already got a number of PMDs for various eth devices, it even has
>> PMD emulations for backends such as pcap, sw rings etc.
>>
>> I've been thinking about the idea of having PMD which would generate
>> mbufs on the fly in some randomized fashion. This would serve goals
>> like, for example:
>>
>> 1) running tests for applications with network processing capabilities
>> without additional software packet generators;
>> 2) making performance measurements with no hw inteference;
>> 3) ability to run without root privileges, --no-pci, --no-huge, for CI
>> build, so on.
>>
>> Maybe there's no such need, and these goals may be achieved by other
>> means and this idea is flawed? Any thoughts?
> How about a Perl/Python script to generate a PCAP file with random packets 
> and then feed the PCAP file to the PCAP PMD?
>
> Random can mean different requirements for different users/application, I 
> think it is difficult to fit this  under a simple generic API. Customizing 
> the script for different requirements if a far better option in my opinion.

AFAIK, the thing about pcap pmd is that one needs to rewind pcap file 
once pcap pmd reaches its end. It requires additional (non-generic) 
handling in app code.


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

2016-06-15 Thread Hunt, David


On 15/6/2016 3:47 PM, Jan Viktorin wrote:
> On Wed, 15 Jun 2016 16:10:13 +0200
> Olivier MATZ  wrote:
>
>> On 06/15/2016 04:02 PM, Hunt, David wrote:
>>>
>>> On 15/6/2016 2:50 PM, Olivier MATZ wrote:
 Hi David,

 On 06/15/2016 02:38 PM, Hunt, David wrote:
>
> On 15/6/2016 1:03 PM, Olivier MATZ wrote:
>> Hi,
>>
>> On 06/15/2016 01:47 PM, Hunt, David wrote:
>>>
>>> On 15/6/2016 11:13 AM, Jan Viktorin wrote:
 Hi,

 I've got one last question. Initially, I was interested in creating
 my own external memory provider based on a Linux Kernel driver.
 So, I've got an opened file descriptor that points to a device which
 can mmap a memory regions for me.

 ...
 int fd = open("/dev/uio0" ...);
 ...
 rte_mempool *pool = rte_mempool_create_empty(...);
 rte_mempool_set_ops_byname(pool, "uio_allocator_ops");

 I am not sure how to pass the file descriptor pointer. I thought it
 would
 be possible by the rte_mempool_alloc but it's not... Is it possible
 to solve this case?

 The allocator is device-specific.

 Regards
 Jan
>>> This particular use case is not covered.
>>>
>>> We did discuss this before, and an opaque pointer was proposed, but
>>> did
>>> not make it in.
>>> http://article.gmane.org/gmane.comp.networking.dpdk.devel/39821
>>> (and following emails in that thread)
>>>
>>> So, the options for this use case are as follows:
>>> 1. Use the pool_data to pass data in to the alloc, then set the
>>> pool_data pointer before coming back from alloc. (It's a bit of a
>>> hack,
>>> but means no code change).
>>> 2. Add an extra parameter to the alloc function. The simplest way I
>>> can
>>> think of doing this is to
>>> take the *opaque passed into rte_mempool_populate_phys, and pass it on
>>> into the alloc function.
>>> This will have minimal impact on the public API,s as there is
>>> already an
>>> opaque there in the _populate_ funcs, we're just
>>> reusing it for the alloc.
>>>
>>> Do others think option 2 is OK to add this at this late stage? Even if
>>> the patch set has already been ACK'd?
>> Jan's use-case looks to be relevant.
>>
>> What about changing:
>>
>>rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name)
>>
>> into:
>>
>>   rte_mempool_set_ops(struct rte_mempool *mp, const char *name,
>>  void *opaque)
> Or a third function?
>
> rte_mempool_set_ops_arg(struct rte_mempool, *mp, void *arg)

I think if we tried to add another function, there would be some 
opposition to that.
I think it's reasonable to add it to set_ops_byname, as we're setting 
the ops and
the ops_args in the same call. We use them later in the alloc.

>
> Or isn't it really a task for a kind of rte_mempool_populate_*?

I was leaning towards that, but a different proposal was suggested. I'm 
OK with
adding the *opaque to set_ops_byname

> This is a part of mempool I am not involved in yet.
>
>> ?
>>
>> The opaque pointer would be saved in mempool structure, and used
>> when the mempool is populated (calling mempool_ops_alloc).
>> The type of the structure pointed by the opaque has to be defined
>> (and documented) into each mempool_ops manager.
>>   
> Yes, that was another option, which has the additional impact of
> needing an
> opaque added to the mempool struct. If we use the opaque from the
> _populate_
> function, we use it straight away in the alloc, no storage needed.
>
> Also, do you think we need to go ahead with this change, or can we add
> it later as an
> improvement?
 The opaque in populate_phys() is already used for something else
 (i.e. the argument for the free callback of the memory chunk).
 I'm afraid it could cause confusion to have it used for 2 different
 things.

 About the change, I think it could be good to have it in 16.11,
 because it will probably change the API, and we should avoid to
 change it each version ;)

 So I'd vote to have it in the patchset for consistency.
>>> Sure, we should avoid breaking API just after we created it. :)
>>>
>>> OK, here's a slightly different proposal.
>>>
>>> If we add a string, to the _ops_byname, yes, that will work for Jan's case.
> A string? No, I needed to pass a file descriptor or a pointer to some 
> rte_device
> or something like that. So a void * is a way to go.

Apologies, I misread. *opaque it is.

>>> However, if we add a void*, that allow us the flexibility of passing
>>> anything we
>>> want. We can then store the void* in the mempool struct as void
>>> *pool_config,
> void *ops_context, ops_args, ops_data, ...

I think I'll go with ops_args

>>> so that when the alloc gets called, it 

[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] eal: Fix wrong resource release of pci_uio_unmap()

2016-06-15 Thread David Marchand
On Wed, Jun 15, 2016 at 5:27 AM, Tetsuya Mukawa  wrote:
> 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 

Function name in title.

> ---
>  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);
> }
>  }
>

The rest looks good to me.

-- 
David Marchand


[dpdk-dev] [PATCH] igb_uio: fix build with backported kernel

2016-06-15 Thread Ferruh Yigit
On 6/15/2016 4:57 PM, Ferruh Yigit wrote:
> Following compile error observed with CentOS 6.8, which uses kernel
> kernel-devel-2.6.32-642.el6.x86_64:
> 
> CC eal_thread.o
> .../build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c:
> In function 'igbuio_msix_mask_irq':
> .../build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c:157:
> error: 'PCI_MSIX_ENTRY_CTRL_MASKBIT' undeclared (first use in this
> function)
> 
> Reported-by: Thiago 
> Signed-off-by: Ferruh Yigit 

Hi Thiago,

Can you please test this patch?

Thanks,
ferruh



[dpdk-dev] [PATCH] igb_uio: fix build with backported kernel

2016-06-15 Thread Ferruh Yigit
Following compile error observed with CentOS 6.8, which uses kernel
kernel-devel-2.6.32-642.el6.x86_64:

CC eal_thread.o
.../build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c:
In function 'igbuio_msix_mask_irq':
.../build/lib/librte_eal/linuxapp/igb_uio/igb_uio.c:157:
error: 'PCI_MSIX_ENTRY_CTRL_MASKBIT' undeclared (first use in this
function)

Reported-by: Thiago 
Signed-off-by: Ferruh Yigit 
---
 lib/librte_eal/linuxapp/igb_uio/compat.h | 9 +
 1 file changed, 9 insertions(+)

diff --git a/lib/librte_eal/linuxapp/igb_uio/compat.h 
b/lib/librte_eal/linuxapp/igb_uio/compat.h
index c1d45a6..0d781e4 100644
--- a/lib/librte_eal/linuxapp/igb_uio/compat.h
+++ b/lib/librte_eal/linuxapp/igb_uio/compat.h
@@ -24,6 +24,15 @@
 #define   PCI_MSIX_ENTRY_CTRL_MASKBIT   1
 #endif

+/*
+ * for kernels < 2.6.38 and backported patch that moves MSI-X entry definition
+ * to pci_regs.h Those kernels has PCI_MSIX_ENTRY_SIZE defined but not
+ * PCI_MSIX_ENTRY_CTRL_MASKBIT
+ */
+#ifndef PCI_MSIX_ENTRY_CTRL_MASKBIT
+#define PCI_MSIX_ENTRY_CTRL_MASKBIT1
+#endif
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 34) && \
(!(defined(RHEL_RELEASE_CODE) && \
 RHEL_RELEASE_CODE >= RHEL_RELEASE_VERSION(5, 9)))
-- 
2.5.5



[dpdk-dev] [PATCH] ethdev: clarify the origin of mbufs

2016-06-15 Thread Thomas Monjalon
2016-06-13 15:45, Olivier Matz:
> Following the discussion on dpdk-users [1], enhance the API
> documentation of rte_eth_tx_burst() to specify that the mbufs have to be
> allocated from a pool.
> 
> [1] http://dpdk.org/ml/archives/users/2016-June/000618.html
> 
> Reported-by: Wu Xiaoban 
> Signed-off-by: Olivier Matz 

Applied, thanks


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

2016-06-15 Thread David Marchand
On Wed, Jun 15, 2016 at 5:26 AM, Tetsuya Mukawa  wrote:
> Currently, a return value of strdup() isn't checked correctly.
> The patch fixes it.
>
> Signed-off-by: Tetsuya Mukawa 

Idem, the title does not need the function name to describe what is going wrong.

This might deserve a fixline, I traced this to 0fe11ec592b2 ("eal: add
vdev init and uninit").

> ---
>  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
>

-- 
David Marchand


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

2016-06-15 Thread Jan Viktorin
On Wed, 15 Jun 2016 16:10:13 +0200
Olivier MATZ  wrote:

> On 06/15/2016 04:02 PM, Hunt, David wrote:
> >
> >
> > On 15/6/2016 2:50 PM, Olivier MATZ wrote:  
> >> Hi David,
> >>
> >> On 06/15/2016 02:38 PM, Hunt, David wrote:  
> >>>
> >>>
> >>> On 15/6/2016 1:03 PM, Olivier MATZ wrote:  
>  Hi,
> 
>  On 06/15/2016 01:47 PM, Hunt, David wrote:  
> >
> >
> > On 15/6/2016 11:13 AM, Jan Viktorin wrote:  
> >> Hi,
> >>
> >> I've got one last question. Initially, I was interested in creating
> >> my own external memory provider based on a Linux Kernel driver.
> >> So, I've got an opened file descriptor that points to a device which
> >> can mmap a memory regions for me.
> >>
> >> ...
> >> int fd = open("/dev/uio0" ...);
> >> ...
> >> rte_mempool *pool = rte_mempool_create_empty(...);
> >> rte_mempool_set_ops_byname(pool, "uio_allocator_ops");
> >>
> >> I am not sure how to pass the file descriptor pointer. I thought it
> >> would
> >> be possible by the rte_mempool_alloc but it's not... Is it possible
> >> to solve this case?
> >>
> >> The allocator is device-specific.
> >>
> >> Regards
> >> Jan  
> >
> > This particular use case is not covered.
> >
> > We did discuss this before, and an opaque pointer was proposed, but
> > did
> > not make it in.
> > http://article.gmane.org/gmane.comp.networking.dpdk.devel/39821
> > (and following emails in that thread)
> >
> > So, the options for this use case are as follows:
> > 1. Use the pool_data to pass data in to the alloc, then set the
> > pool_data pointer before coming back from alloc. (It's a bit of a
> > hack,
> > but means no code change).
> > 2. Add an extra parameter to the alloc function. The simplest way I
> > can
> > think of doing this is to
> > take the *opaque passed into rte_mempool_populate_phys, and pass it on
> > into the alloc function.
> > This will have minimal impact on the public API,s as there is
> > already an
> > opaque there in the _populate_ funcs, we're just
> > reusing it for the alloc.
> >
> > Do others think option 2 is OK to add this at this late stage? Even if
> > the patch set has already been ACK'd?  
> 
>  Jan's use-case looks to be relevant.
> 
>  What about changing:
> 
>    rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name)
> 
>  into:
> 
>   rte_mempool_set_ops(struct rte_mempool *mp, const char *name,
>  void *opaque)

Or a third function?

rte_mempool_set_ops_arg(struct rte_mempool, *mp, void *arg)

Or isn't it really a task for a kind of rte_mempool_populate_*?

This is a part of mempool I am not involved in yet.

> 
>  ?
> 
>  The opaque pointer would be saved in mempool structure, and used
>  when the mempool is populated (calling mempool_ops_alloc).
>  The type of the structure pointed by the opaque has to be defined
>  (and documented) into each mempool_ops manager.
>   
> >>>
> >>> Yes, that was another option, which has the additional impact of
> >>> needing an
> >>> opaque added to the mempool struct. If we use the opaque from the
> >>> _populate_
> >>> function, we use it straight away in the alloc, no storage needed.
> >>>
> >>> Also, do you think we need to go ahead with this change, or can we add
> >>> it later as an
> >>> improvement?  
> >>
> >> The opaque in populate_phys() is already used for something else
> >> (i.e. the argument for the free callback of the memory chunk).
> >> I'm afraid it could cause confusion to have it used for 2 different
> >> things.
> >>
> >> About the change, I think it could be good to have it in 16.11,
> >> because it will probably change the API, and we should avoid to
> >> change it each version ;)
> >>
> >> So I'd vote to have it in the patchset for consistency.  
> >
> > Sure, we should avoid breaking API just after we created it. :)
> >
> > OK, here's a slightly different proposal.
> >
> > If we add a string, to the _ops_byname, yes, that will work for Jan's case.

A string? No, I needed to pass a file descriptor or a pointer to some rte_device
or something like that. So a void * is a way to go.

> > However, if we add a void*, that allow us the flexibility of passing
> > anything we
> > want. We can then store the void* in the mempool struct as void
> > *pool_config,

void *ops_context, ops_args, ops_data, ...

> > so that when the alloc gets called, it can access whatever is stored at
> > *pool_config
> > and do the correct initialisation/allocation. In Jan's use case, this
> > can simply be typecast
> > to a string. In future cases, it can be a struct, which could including
> > new flags.

New flags? Does it mean an API extension?

> 
> Yep, agree. But not sure I'm seeing the difference with what I
> proposed.

Me neither... I think it is exactly the same :).

Jan


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

2016-06-15 Thread David Marchand
Hello Tetsuya,

On Wed, Jun 15, 2016 at 5:26 AM, Tetsuya Mukawa  wrote:
> 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 

The title should not contain the function name.


> ---
>  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;
> }
> }

What of the previous mappings that might have succeeded earlier in this loop ?


-- 
David Marchand


[dpdk-dev] random pkt generator PMD

2016-06-15 Thread Arnon Warshavsky
On Wed, Jun 15, 2016 at 4:03 PM, Dumitrescu, Cristian <
cristian.dumitrescu at intel.com> wrote:

>
>
> > -Original Message-
> > From: Yerden Zhumabekov [mailto:e_zhumabekov at sts.kz]
> > Sent: Wednesday, June 15, 2016 1:55 PM
> > To: Dumitrescu, Cristian ; Panu
> Matilainen
> > ; dev at dpdk.org
> > Subject: Re: [dpdk-dev] random pkt generator PMD
> >
> >
> >
> > On 15.06.2016 18:25, Dumitrescu, Cristian wrote:
> >
> >  So add a loop-mode to pcap pmd?
> > >>> It would be nice to have an option like "...,rewind=1,...".
> > >> As Cristian points out in
> > >> http://dpdk.org/ml/archives/dev/2016-June/041589.html, the current
> > pmd
> > >> behavior of stopping is the odd man out in the pmd crowd.
> > >>
> > >> Rather than whether to rewind or not, I'd make the number of loops
> > >> configurable, defaulting to forever and 1 being the equal to current
> > >> behavior.
> > >>
> > >>- Panu -
> > > +1
> >
> > I'm afraid, all packets from pcap file would need to be preloaded to
> > memory. Otherwise, each loop would infer pcap_open/pcap_close(), am I
> > wrong?
>
> This exactly what the code in source port is doing.
>
> Basically, this is optimized for the case when number of packets in the
> PCAP file is relatively small, so the PCAP memory footprint when loaded
> into memory is small so it fits the L1/L2 cache. Provides traffic
> generation capability when performance measurements are not key: testing,
> code development on your laptop while on board of a plane, simulation
> environments, etc.
>
> When the PCAP is large (e.g. capture of the traffic in your local cloud
> for 2 mins), then PCAP memory gets swapped to disk and performance
> obviously drops. Still better than opening PCAC for each packet. Useful for
> e.g. IDS/IPS testing.
>


If you are after continuous traffic that varies all the time in high
performance rather than loop the same pcap over and over again,
check out  the T-Rex traffic generator which is an open source and dpdk
based.
https://trex-tgn.cisco.com/

/Arnon


[dpdk-dev] [PATCH] examples: fix duplicated lpm6 name

2016-06-15 Thread Thomas Monjalon
2016-06-13 11:43, Olivier Matz:
> When starting the ip_fragmentation or ip_reassembly example
> on several sockets, it fails.
> 
> The name of the lpm6 table is the same on every socket,
> resulting in a table creation failure (-EEXIST). The failure
> appeared after:
> commit f82f705b635d ("lpm: fix allocation of an existing object")
> 
> Indeed, before this commit the returned value when the existing
> table, which was probably a bug in that case: one table for 2
> sockets for lpm6, and one per socket for lpm.
> 
> Fixes: 74de12b7b63a ("examples/ip_fragmentation: overhaul")
> Fixes: b84fb4cb88ff ("examples/ip_reassembly: overhaul")
> Reported-by: Ding Heng 
> Signed-off-by: Olivier Matz 

Applied, thanks


[dpdk-dev] [PATCH v5 01/38] bnxt: new driver for Broadcom NetXtreme-C devices

2016-06-15 Thread Bruce Richardson
On Tue, Jun 14, 2016 at 03:55:34PM -0700, Stephen Hurd wrote:
> From: Ajit Khaparde 
> 
> This patch adds the initial skeleton for bnxt driver along with the
> nic guide to tie into the build system.
> At this point, the driver simply fails init.
> 
> Signed-off-by: Ajit Khaparde 
> Signed-off-by: Stephen Hurd 
> Reviewed-by: David Christensen 
> 
> --
> v4:
> Fix a warning that the document isn't included in any toctree
> Also remove a PCI ID added erroneously.
> 
> v5:
> Re-format footer
> ---
>  MAINTAINERS |   5 ++
>  config/common_base  |   5 ++
>  doc/guides/nics/bnxt.rst|  49 +++
>  doc/guides/nics/index.rst   |   1 +

Sorry I missed this in earlier reviews, but an update to the overview.rst doc
is missing here. It needs a new column added for the new driver.

Regards,
/Bruce



[dpdk-dev] [PATCH v5 01/38] bnxt: new driver for Broadcom NetXtreme-C devices

2016-06-15 Thread Bruce Richardson
One reminder for when sending future patchset - or other revisions of this
set, please include a cover letter. Any patchset over 4/5 patches generally
needs one, and it allows us to see the combined diffstats for the whole set.

/Bruce

On Tue, Jun 14, 2016 at 03:55:34PM -0700, Stephen Hurd wrote:
> From: Ajit Khaparde 
> 
> This patch adds the initial skeleton for bnxt driver along with the
> nic guide to tie into the build system.
> At this point, the driver simply fails init.
> 
> Signed-off-by: Ajit Khaparde 
> Signed-off-by: Stephen Hurd 
> Reviewed-by: David Christensen 
> 
> --
> v4:
> Fix a warning that the document isn't included in any toctree
> Also remove a PCI ID added erroneously.
> 
> v5:
> Re-format footer


[dpdk-dev] [PATCH v4 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  |   5 +-
 examples/l2fwd-keepalive/ka-agent/Makefile |  49 ++
 examples/l2fwd-keepalive/ka-agent/main.c   | 150 +
 examples/l2fwd-keepalive/main.c|  22 -
 examples/l2fwd-keepalive/shm.c | 129 +
 examples/l2fwd-keepalive/shm.h |  89 +
 7 files changed, 441 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..ca45a79 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,9 +42,10 @@ 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)
+LDFLAGS += -lrt

 include $(RTE_SDK)/mk/rte.extapp.mk
diff --git a/examples/l2fwd-keepalive/ka-agent/Makefile 
b/examples/l2fwd-keepalive/ka-agent/Makefile
new file mode 100644
index 000..fd0c38b
--- /dev/null
+++ b/examples/l2fwd-keepalive/ka-agent/Makefile
@@ -0,0 +1,49 @@
+#   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)/../
+LDFLAGS += -lrt
+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..be1c7f4
--- /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 

[dpdk-dev] [PATCH v4 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 |  2 +
 6 files changed, 91 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 d01a654..88ad8e4 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 8b14370..9765d1b 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 v4 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..d01a654 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_KA_STATE_UNUSED = 0,
+   RTE_KA_STATE_ALIVE = 1,
+   RTE_KA_STATE_MISSING = 4,
+   RTE_KA_STATE_DEAD = 2,
+   RTE_KA_STATE_GONE = 3,
+   RTE_KA_STATE_DOZING = 5,
+   RTE_KA_STATE_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..8b14370 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_KA_STATE_UNUSED:
+   break;
+   case RTE_KA_STATE_ALIVE: /* Alive */
+   keepcfg->state_flags[idx_core] = RTE_KA_STATE_MISSING;
keepcfg->last_alive[idx_core] = rte_rdtsc();
break;
-   case MISSING: /* MIA */
+   case RTE_KA_STATE_MISSING: /* MIA */
print_trace("Core MIA. ", keepcfg, idx_core);
-   keepcfg->state_flags[idx_core] = DEAD;
+   keepcfg->state_flags[idx_core] = RTE_KA_STATE_DEAD;
break;
-   case DEAD: /* Dead */
-   keepcfg->state_flags[idx_core] = GONE;
+   case RTE_KA_STATE_DEAD: /* Dead */
+   keepcfg->state_flags[idx_core] = RTE_KA_STATE_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_KA_STATE_GONE: /* Buried */
+   break;
+   case RTE_KA_STATE_DOZING: /* Core going idle */
+   keepcfg->state_flags[idx_core] = RTE_KA_STATE_SLEEP;
+   keepcfg->last_alive[idx_core] = rte_rdtsc();
+   break;
+   case RTE_KA_STATE_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_KA_STATE_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_KA_STATE_ALIVE;
 }
-- 
2.5.5



[dpdk-dev] [PATCH v4 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 l2fwd-keepalive example.

--

v4 changes
* Use RTE_KA_STATE_ prefix instead of RTE_ (namespace issues)

v3 changes
* Rebased to master
* Exposed keepalive state enumerations
* 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   |   5 +-
 examples/l2fwd-keepalive/ka-agent/Makefile  |  49 
 examples/l2fwd-keepalive/ka-agent/main.c| 150 
 examples/l2fwd-keepalive/main.c |  22 +++-
 examples/l2fwd-keepalive/shm.c  | 129 
 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 |   2 +
 12 files changed, 562 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 v5 7/7] rte: change xstats usage to new API

2016-06-15 Thread 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.

Signed-off-by: Remy Horton 
---
 app/proc_info/main.c   | 29 +---
 app/test-pmd/config.c  | 54 +-
 drivers/net/e1000/igb_ethdev.c | 10 +++
 drivers/net/fm10k/fm10k_ethdev.c   |  5 +---
 drivers/net/i40e/i40e_ethdev.c |  8 ++
 drivers/net/i40e/i40e_ethdev_vf.c  |  5 ++--
 drivers/net/ixgbe/ixgbe_ethdev.c   | 11 +++-
 drivers/net/virtio/virtio_ethdev.c |  6 ++---
 lib/librte_ether/rte_ethdev.c  |  5 +---
 lib/librte_ether/rte_ethdev.h  |  7 +++--
 10 files changed, 85 insertions(+), 55 deletions(-)

diff --git a/app/proc_info/main.c b/app/proc_info/main.c
index 5f83092..f2063fa 100644
--- a/app/proc_info/main.c
+++ b/app/proc_info/main.c
@@ -1,7 +1,7 @@
 /*
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 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
@@ -243,11 +243,13 @@ nic_stats_clear(uint8_t port_id)
 static void
 nic_xstats_display(uint8_t port_id)
 {
-   struct rte_eth_xstats *xstats;
+   struct rte_eth_xstat_name *xstats_names;
+   struct rte_eth_xstat *xstats;
int len, ret, i;
+   int idx_name;
static const char *nic_stats_border = "";

-   len = rte_eth_xstats_get(port_id, NULL, 0);
+   len = rte_eth_xstats_get_names(port_id, NULL, 0);
if (len < 0) {
printf("Cannot get xstats count\n");
return;
@@ -258,6 +260,18 @@ nic_xstats_display(uint8_t port_id)
return;
}

+   xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * len);
+   if (xstats_names == NULL) {
+   printf("Cannot allocate memory for xstat names\n");
+   free(xstats);
+   return;
+   }
+   if (len != rte_eth_xstats_get_names(
+   port_id, xstats_names, len)) {
+   printf("Cannot get xstat names\n");
+   return;
+   }
+
printf("## NIC extended statistics for port %-2d #\n",
   port_id);
printf("%s\n",
@@ -270,11 +284,18 @@ nic_xstats_display(uint8_t port_id)
}

for (i = 0; i < len; i++)
-   printf("%s: %"PRIu64"\n", xstats[i].name, xstats[i].value);
+   for (idx_name = 0; idx_name < len; idx_name++)
+   if (xstats_names[idx_name].id == xstats[i].id) {
+   printf("%s: %"PRIu64"\n",
+   xstats_names[idx_name].name,
+   xstats[i].value);
+   break;
+   }

printf("%s\n",
   nic_stats_border);
free(xstats);
+   free(xstats_names);
 }

 static void
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 1c552e4..8ddec07 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1,7 +1,7 @@
 /*-
  *   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
@@ -232,29 +232,57 @@ nic_stats_clear(portid_t port_id)
 void
 nic_xstats_display(portid_t port_id)
 {
-   struct rte_eth_xstats *xstats;
-   int len, ret, i;
+   struct rte_eth_xstat *xstats;
+   int cnt_xstats, idx_xstat, idx_name;
+   struct rte_eth_xstat_name *xstats_names;

printf("## NIC extended statistics for port %-2d\n", port_id);
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   printf("Error: Invalid port number %i\n", port_id);
+   return;
+   }
+
+   /* Get count */
+   cnt_xstats = rte_eth_xstats_get_names(port_id, NULL, 0);
+   if (cnt_xstats  < 0) {
+   printf("Error: Cannot get count of xstats\n");
+   return;
+   }

-   len = rte_eth_xstats_get(port_id, NULL, 0);
-   if (len < 0) {
-   printf("Cannot get xstats count\n");
+   /* Get id-name lookup table */
+   xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * cnt_xstats);
+   if (xstats_names == NULL) {
+   printf("Cannot allocate memory for xstats lookup\n");
return;
}
-   xstats = malloc(sizeof(xstats[0]) * len);
+   if (cnt_xstats != 

[dpdk-dev] [PATCH v5 6/7] drivers/net/virtio: change xstats to use integer ids

2016-06-15 Thread 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 virtio driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/virtio/virtio_ethdev.c | 62 +-
 1 file changed, 55 insertions(+), 7 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index c3fb628..83df025 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 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
@@ -80,6 +80,9 @@ static void virtio_dev_stats_get(struct rte_eth_dev *dev,
 struct rte_eth_stats *stats);
 static int virtio_dev_xstats_get(struct rte_eth_dev *dev,
 struct rte_eth_xstats *xstats, unsigned n);
+static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
+  struct rte_eth_xstat_name *xstats_names,
+  unsigned limit);
 static void virtio_dev_stats_reset(struct rte_eth_dev *dev);
 static void virtio_dev_free_mbufs(struct rte_eth_dev *dev);
 static int virtio_vlan_filter_set(struct rte_eth_dev *dev,
@@ -615,6 +618,7 @@ static const struct eth_dev_ops virtio_eth_dev_ops = {
.dev_infos_get   = virtio_dev_info_get,
.stats_get   = virtio_dev_stats_get,
.xstats_get  = virtio_dev_xstats_get,
+   .xstats_get_names= virtio_dev_xstats_get_names,
.stats_reset = virtio_dev_stats_reset,
.xstats_reset= virtio_dev_stats_reset,
.link_update = virtio_dev_link_update,
@@ -708,6 +712,52 @@ virtio_update_stats(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)
stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
 }

+static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
+  struct rte_eth_xstat_name *xstats_names,
+  __rte_unused unsigned limit)
+{
+   unsigned i;
+   unsigned count = 0;
+   unsigned t;
+
+   unsigned nstats = dev->data->nb_tx_queues * VIRTIO_NB_Q_XSTATS +
+   dev->data->nb_rx_queues * VIRTIO_NB_Q_XSTATS;
+
+   if (xstats_names == NULL) {
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   struct virtqueue *rxvq = dev->data->rx_queues[i];
+   if (rxvq == NULL)
+   continue;
+   for (t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "rx_q%u_%s", i,
+   rte_virtio_q_stat_strings[t].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   struct virtqueue *txvq = dev->data->tx_queues[i];
+   if (txvq == NULL)
+   continue;
+   for (t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "tx_q%u_%s", i,
+   rte_virtio_q_stat_strings[t].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+   return count;
+   }
+   return nstats;
+}
+
 static int
 virtio_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
  unsigned n)
@@ -730,9 +780,8 @@ virtio_dev_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,
unsigned t;

for (t = 0; t < VIRTIO_NB_Q_XSTATS; t++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"rx_q%u_%s", i,
-rte_virtio_q_stat_strings[t].name);
+   xstats[count].name[0] = '\0';
+   xstats[count].id = count;
xstats[count].value = *(uint64_t *)(((char *)rxvq) +

[dpdk-dev] [PATCH v5 5/7] drivers/net/i40e: change xstats to use integer ids

2016-06-15 Thread 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 i40e driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/i40e/i40e_ethdev.c| 82 ---
 drivers/net/i40e/i40e_ethdev_vf.c | 26 +++--
 2 files changed, 91 insertions(+), 17 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 24777d5..d712bbe 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2010-2015 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
@@ -306,6 +306,9 @@ static void i40e_dev_stats_get(struct rte_eth_dev *dev,
   struct rte_eth_stats *stats);
 static int i40e_dev_xstats_get(struct rte_eth_dev *dev,
   struct rte_eth_xstats *xstats, unsigned n);
+static int i40e_dev_xstats_get_names(struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+unsigned limit);
 static void i40e_dev_stats_reset(struct rte_eth_dev *dev);
 static int i40e_dev_queue_stats_mapping_set(struct rte_eth_dev *dev,
uint16_t queue_id,
@@ -467,6 +470,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
.link_update  = i40e_dev_link_update,
.stats_get= i40e_dev_stats_get,
.xstats_get   = i40e_dev_xstats_get,
+   .xstats_get_names = i40e_dev_xstats_get_names,
.stats_reset  = i40e_dev_stats_reset,
.xstats_reset = i40e_dev_stats_reset,
.queue_stats_mapping_set  = i40e_dev_queue_stats_mapping_set,
@@ -2205,6 +2209,60 @@ i40e_xstats_calc_num(void)
(I40E_NB_TXQ_PRIO_XSTATS * 8);
 }

+static int i40e_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+__rte_unused unsigned limit)
+{
+   unsigned count = 0;
+   unsigned i, prio;
+
+   if (xstats_names == NULL)
+   return i40e_xstats_calc_num();
+
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   /* Get stats from i40e_eth_stats struct */
+   for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+sizeof(xstats_names[count].name),
+"%s", rte_i40e_stats_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+
+   /* Get individiual stats from i40e_hw_port struct */
+   for (i = 0; i < I40E_NB_HW_PORT_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+"%s", rte_i40e_hw_port_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+
+   for (i = 0; i < I40E_NB_RXQ_PRIO_XSTATS; i++) {
+   for (prio = 0; prio < 8; prio++) {
+   snprintf(xstats_names[count].name,
+sizeof(xstats_names[count].name),
+"rx_priority%u_%s", prio,
+rte_i40e_rxq_prio_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+
+   for (i = 0; i < I40E_NB_TXQ_PRIO_XSTATS; i++) {
+   for (prio = 0; prio < 8; prio++) {
+   snprintf(xstats_names[count].name,
+sizeof(xstats_names[count].name),
+"tx_priority%u_%s", prio,
+rte_i40e_txq_prio_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+   return count;
+}
+
 static int
 i40e_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
unsigned n)
@@ -2227,8 +2285,8 @@ i40e_dev_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,

/* Get stats from i40e_eth_stats struct */
for (i = 0; i < I40E_NB_ETH_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"%s", rte_i40e_stats_strings[i].name);
+   xstats[count].name[0] = '\0';
+   xstats[count].id = count;
xstats[count].value = *(uint64_t 

[dpdk-dev] [PATCH v5 4/7] drivers/net/fm10k: change xstats to use integer ids

2016-06-15 Thread 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 fm10k driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/fm10k/fm10k_ethdev.c | 55 +---
 1 file changed, 46 insertions(+), 9 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index c2d377f..e07c1ec 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1,7 +1,7 @@
 /*-
  *   BSD LICENSE
  *
- *   Copyright(c) 2013-2015 Intel Corporation. All rights reserved.
+ *   Copyright(c) 2013-2016 Intel Corporation. All rights reserved.
  *   All rights reserved.
  *
  *   Redistribution and use in source and binary forms, with or without
@@ -1256,6 +1256,47 @@ fm10k_link_update(struct rte_eth_dev *dev,
return 0;
 }

+static int fm10k_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit)
+{
+   unsigned i, q;
+   unsigned count = 0;
+
+   if (xstats_names != NULL) {
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   /* Global stats */
+   for (i = 0; i < FM10K_NB_HW_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "%s", fm10k_hw_stats_strings[count].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+
+   /* PF queue stats */
+   for (q = 0; q < FM10K_MAX_QUEUES_PF; q++) {
+   for (i = 0; i < FM10K_NB_RX_Q_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "rx_q%u_%s", q,
+   fm10k_hw_stats_rx_q_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   for (i = 0; i < FM10K_NB_TX_Q_XSTATS; i++) {
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "tx_q%u_%s", q,
+   fm10k_hw_stats_tx_q_strings[i].name);
+   xstats_names[count].id = count;
+   count++;
+   }
+   }
+   }
+   return FM10K_NB_XSTATS;
+}
+
 static int
 fm10k_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
 unsigned n)
@@ -1269,8 +1310,7 @@ fm10k_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,

/* Global stats */
for (i = 0; i < FM10K_NB_HW_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"%s", fm10k_hw_stats_strings[count].name);
+   xstats[count].name[0] = '\0';
xstats[count].value = *(uint64_t *)(((char *)hw_stats) +
fm10k_hw_stats_strings[count].offset);
count++;
@@ -1279,18 +1319,14 @@ fm10k_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,
/* PF queue stats */
for (q = 0; q < FM10K_MAX_QUEUES_PF; q++) {
for (i = 0; i < FM10K_NB_RX_Q_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"rx_q%u_%s", q,
-fm10k_hw_stats_rx_q_strings[i].name);
+   xstats[count].name[0] = '\0';
xstats[count].value =
*(uint64_t *)(((char *)_stats->q[q]) +
fm10k_hw_stats_rx_q_strings[i].offset);
count++;
}
for (i = 0; i < FM10K_NB_TX_Q_XSTATS; i++) {
-   snprintf(xstats[count].name, sizeof(xstats[count].name),
-"tx_q%u_%s", q,
-fm10k_hw_stats_tx_q_strings[i].name);
+   xstats[count].name[0] = '\0';
xstats[count].value =
*(uint64_t *)(((char *)_stats->q[q]) +
fm10k_hw_stats_tx_q_strings[i].offset);
@@ -2629,6 +2665,7 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
.allmulticast_disable   = fm10k_dev_allmulticast_disable,
.stats_get  = fm10k_stats_get,
.xstats_get = fm10k_xstats_get,
+   .xstats_get_names   = 

[dpdk-dev] [PATCH v5 3/7] drivers/net/e1000: change xstats to use integer ids

2016-06-15 Thread 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 e1000 driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/e1000/igb_ethdev.c | 52 ++
 1 file changed, 48 insertions(+), 4 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index f0921ee..dffa04f 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -100,6 +100,9 @@ static void eth_igb_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *rte_stats);
 static int eth_igb_xstats_get(struct rte_eth_dev *dev,
  struct rte_eth_xstats *xstats, unsigned n);
+static int eth_igb_xstats_get_names(struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names,
+   unsigned limit);
 static void eth_igb_stats_reset(struct rte_eth_dev *dev);
 static void eth_igb_xstats_reset(struct rte_eth_dev *dev);
 static void eth_igb_infos_get(struct rte_eth_dev *dev,
@@ -165,6 +168,9 @@ static void eth_igbvf_stats_get(struct rte_eth_dev *dev,
struct rte_eth_stats *rte_stats);
 static int eth_igbvf_xstats_get(struct rte_eth_dev *dev,
struct rte_eth_xstats *xstats, unsigned n);
+static int eth_igbvf_xstats_get_names(struct rte_eth_dev *dev,
+ struct rte_eth_xstat_name *xstats_names,
+ unsigned limit);
 static void eth_igbvf_stats_reset(struct rte_eth_dev *dev);
 static int igbvf_vlan_filter_set(struct rte_eth_dev *dev,
uint16_t vlan_id, int on);
@@ -324,6 +330,7 @@ static const struct eth_dev_ops eth_igb_ops = {
.link_update  = eth_igb_link_update,
.stats_get= eth_igb_stats_get,
.xstats_get   = eth_igb_xstats_get,
+   .xstats_get_names = eth_igb_xstats_get_names,
.stats_reset  = eth_igb_stats_reset,
.xstats_reset = eth_igb_xstats_reset,
.dev_infos_get= eth_igb_infos_get,
@@ -385,6 +392,7 @@ static const struct eth_dev_ops igbvf_eth_dev_ops = {
.link_update  = eth_igb_link_update,
.stats_get= eth_igbvf_stats_get,
.xstats_get   = eth_igbvf_xstats_get,
+   .xstats_get_names = eth_igbvf_xstats_get_names,
.stats_reset  = eth_igbvf_stats_reset,
.xstats_reset = eth_igbvf_stats_reset,
.vlan_filter_set  = igbvf_vlan_filter_set,
@@ -1691,6 +1699,26 @@ eth_igb_xstats_reset(struct rte_eth_dev *dev)
memset(stats, 0, sizeof(*stats));
 }

+static int eth_igb_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names,
+   __rte_unused unsigned limit)
+{
+   unsigned i;
+
+   if (xstats_names == NULL)
+   return IGB_NB_XSTATS;
+
+   /* Note: limit checked in rte_eth_xstats_names() */
+
+   for (i = 0; i < IGB_NB_XSTATS; i++) {
+   snprintf(xstats_names[i].name, sizeof(xstats_names[i].name),
+"%s", rte_igb_stats_strings[i].name);
+   xstats_names[i].id = i;
+   }
+
+   return IGB_NB_XSTATS;
+}
+
 static int
 eth_igb_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstats *xstats,
   unsigned n)
@@ -1713,8 +1741,8 @@ eth_igb_xstats_get(struct rte_eth_dev *dev, struct 
rte_eth_xstats *xstats,

/* Extended stats */
for (i = 0; i < IGB_NB_XSTATS; i++) {
-   snprintf(xstats[i].name, sizeof(xstats[i].name),
-"%s", rte_igb_stats_strings[i].name);
+   xstats[i].name[0] = '\0';
+   xstats[i].id = i;
xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
rte_igb_stats_strings[i].offset);
}
@@ -1762,6 +1790,22 @@ igbvf_read_stats_registers(struct e1000_hw *hw, struct 
e1000_vf_stats *hw_stats)
hw_stats->last_gotlbc, hw_stats->gotlbc);
 }

+static int eth_igbvf_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+struct rte_eth_xstat_name *xstats_names,
+__rte_unused unsigned limit)
+{
+   unsigned i;
+
+   if (xstats_names != NULL)
+   for (i = 0; i < IGBVF_NB_XSTATS; i++) {
+   snprintf(xstats_names[i].name,
+   sizeof(xstats_names[i].name), "%s",
+   rte_igbvf_stats_strings[i].name);
+   xstats_names[i].id = i;
+   }
+   return IGBVF_NB_XSTATS;
+}
+
 static int
 eth_igbvf_xstats_get(struct rte_eth_dev *dev, 

[dpdk-dev] [PATCH v5 2/7] drivers/net/ixgbe: change xstats to use integer ids

2016-06-15 Thread 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 ixgbe driver
to use the new API that seperates name string and value queries.

Signed-off-by: Remy Horton 
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 101 +--
 1 file changed, 86 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index a2b170b..9e73492 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -179,6 +179,10 @@ static int ixgbevf_dev_xstats_get(struct rte_eth_dev *dev,
  struct rte_eth_xstats *xstats, unsigned n);
 static void ixgbe_dev_stats_reset(struct rte_eth_dev *dev);
 static void ixgbe_dev_xstats_reset(struct rte_eth_dev *dev);
+static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
+static int ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit);
 static int ixgbe_dev_queue_stats_mapping_set(struct rte_eth_dev *eth_dev,
 uint16_t queue_id,
 uint8_t stat_idx,
@@ -466,6 +470,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
.xstats_get   = ixgbe_dev_xstats_get,
.stats_reset  = ixgbe_dev_stats_reset,
.xstats_reset = ixgbe_dev_xstats_reset,
+   .xstats_get_names = ixgbe_dev_xstats_get_names,
.queue_stats_mapping_set = ixgbe_dev_queue_stats_mapping_set,
.dev_infos_get= ixgbe_dev_info_get,
.dev_supported_ptypes_get = ixgbe_dev_supported_ptypes_get,
@@ -555,6 +560,7 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = {
.xstats_get   = ixgbevf_dev_xstats_get,
.stats_reset  = ixgbevf_dev_stats_reset,
.xstats_reset = ixgbevf_dev_stats_reset,
+   .xstats_get_names = ixgbevf_dev_xstats_get_names,
.dev_close= ixgbevf_dev_close,
.allmulticast_enable  = ixgbevf_dev_allmulticast_enable,
.allmulticast_disable = ixgbevf_dev_allmulticast_disable,
@@ -685,6 +691,7 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_rxq_strings[] = {

 #define IXGBE_NB_RXQ_PRIO_STATS (sizeof(rte_ixgbe_rxq_strings) / \
   sizeof(rte_ixgbe_rxq_strings[0]))
+#define IXGBE_NB_RXQ_PRIO_VALUES 8

 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_txq_strings[] = {
{"xon_packets", offsetof(struct ixgbe_hw_stats, pxontxc)},
@@ -695,6 +702,7 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_txq_strings[] = {

 #define IXGBE_NB_TXQ_PRIO_STATS (sizeof(rte_ixgbe_txq_strings) / \
   sizeof(rte_ixgbe_txq_strings[0]))
+#define IXGBE_NB_TXQ_PRIO_VALUES 8

 static const struct rte_ixgbe_xstats_name_off rte_ixgbevf_stats_strings[] = {
{"rx_multicast_packets", offsetof(struct ixgbevf_hw_stats, vfmprc)},
@@ -2695,8 +2703,75 @@ ixgbe_dev_stats_reset(struct rte_eth_dev *dev)
 /* This function calculates the number of xstats based on the current config */
 static unsigned
 ixgbe_xstats_calc_num(void) {
-   return IXGBE_NB_HW_STATS + (IXGBE_NB_RXQ_PRIO_STATS * 8) +
-   (IXGBE_NB_TXQ_PRIO_STATS * 8);
+   return IXGBE_NB_HW_STATS +
+   (IXGBE_NB_RXQ_PRIO_STATS * IXGBE_NB_RXQ_PRIO_VALUES) +
+   (IXGBE_NB_TXQ_PRIO_STATS * IXGBE_NB_TXQ_PRIO_VALUES);
+}
+
+static int ixgbe_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
+   struct rte_eth_xstat_name *xstats_names, __rte_unused unsigned limit)
+{
+   const unsigned cnt_stats = ixgbe_xstats_calc_num();
+   unsigned stat, i, count;
+
+   if (xstats_names != NULL) {
+   count = 0;
+
+   /* Note: limit >= cnt_stats checked upstream
+* in rte_eth_xstats_names()
+*/
+
+   /* Extended stats from ixgbe_hw_stats */
+   for (i = 0; i < IXGBE_NB_HW_STATS; i++) {
+   xstats_names[count].id = count;
+   snprintf(xstats_names[count].name,
+   sizeof(xstats_names[count].name),
+   "%s",
+   rte_ixgbe_stats_strings[i].name);
+   count++;
+   }
+
+   /* RX Priority Stats */
+   for (stat = 0; stat < IXGBE_NB_RXQ_PRIO_STATS; stat++) {
+   for (i = 0; i < IXGBE_NB_RXQ_PRIO_VALUES; i++) {
+   xstats_names[count].id = count;
+   snprintf(xstats_names[count].name,
+   

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

2016-06-15 Thread 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 xstats
functions to instead use a numeric identifier rather than a string, and
adds the ability to retrieve identifier-to-string mappings.

Signed-off-by: Remy Horton 
---
 doc/guides/prog_guide/poll_mode_drv.rst | 25 +++--
 lib/librte_ether/rte_ethdev.c   | 93 ++---
 lib/librte_ether/rte_ethdev.h   | 41 +++
 lib/librte_ether/rte_ether_version.map  |  6 +++
 4 files changed, 153 insertions(+), 12 deletions(-)

diff --git a/doc/guides/prog_guide/poll_mode_drv.rst 
b/doc/guides/prog_guide/poll_mode_drv.rst
index 7698692..802fb8f 100644
--- a/doc/guides/prog_guide/poll_mode_drv.rst
+++ b/doc/guides/prog_guide/poll_mode_drv.rst
@@ -299,10 +299,27 @@ Extended Statistics API
 ~~~

 The extended statistics API allows each individual PMD to expose a unique set
-of statistics. The client of the API provides an array of
-``struct rte_eth_xstats`` type. Each ``struct rte_eth_xstats`` contains a
-string and value pair. The amount of xstats exposed, and position of the
-statistic in the array must remain constant during runtime.
+of statistics. Accessing these from application programs is done via two
+functions:
+
+* ``rte_eth_xstats_get``: Fills in an array of ``struct rte_eth_xstat``
+  with extended statistics.
+* ``rte_eth_xstats_get_names``: Fills in an array of
+  ``struct rte_eth_xstat_name`` with extended statistic name lookup
+  information.
+
+Each ``struct rte_eth_xstat`` contains an identifier and value pair, and
+each ``struct rte_eth_xstat_name`` contains an identifier and string pair.
+Each identifier within ``struct rte_eth_xstat`` must have a corresponding
+entry in ``struct rte_eth_xstat_name`` with a matching identifier. These
+identifiers, as well as the number of extended statistic exposed, must
+remain constant during runtime.
+
+Note that extended statistic identifiers are driver-specific, and hence
+might not be the same for different ports. Although it is expected that
+drivers will make the identifiers used within ``struct rte_eth_xstat`` and
+``struct rte_eth_xstat_name`` entries match the entries' array index, this
+property should not be relied on by applications for lookups.

 A naming scheme exists for the strings exposed to clients of the API. This is
 to allow scraping of the API for statistics of interest. The naming scheme uses
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index e148028..98e5efb 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1502,6 +1502,85 @@ rte_eth_stats_reset(uint8_t port_id)
dev->data->rx_mbuf_alloc_failed = 0;
 }

+static int
+get_xstats_count(uint8_t port_id)
+{
+   struct rte_eth_dev *dev;
+   int count;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL);
+   dev = _eth_devices[port_id];
+   if (dev->dev_ops->xstats_get_names != NULL) {
+   count = (*dev->dev_ops->xstats_get_names)(dev, NULL, 0);
+   if (count < 0)
+   return count;
+   } else
+   count = 0;
+   count += RTE_NB_STATS;
+   count += dev->data->nb_rx_queues * RTE_NB_RXQ_STATS;
+   count += dev->data->nb_tx_queues * RTE_NB_TXQ_STATS;
+   return count;
+}
+
+int
+rte_eth_xstats_get_names(uint8_t port_id,
+   struct rte_eth_xstat_name *xstats_names,
+   unsigned size)
+{
+   struct rte_eth_dev *dev;
+   int cnt_used_entries;
+   int cnt_expected_entries;
+   uint32_t idx, id_queue;
+
+   cnt_expected_entries = get_xstats_count(port_id);
+   if (xstats_names == NULL || cnt_expected_entries < 0 ||
+   (int)size < cnt_expected_entries)
+   return cnt_expected_entries;
+
+   /* port_id checked in get_xstats_count() */
+   dev = _eth_devices[port_id];
+   if (dev->dev_ops->xstats_get_names != NULL) {
+   cnt_used_entries = (*dev->dev_ops->xstats_get_names)(
+   dev, xstats_names, size);
+   if (cnt_used_entries < 0)
+   return cnt_used_entries;
+   } else
+   /* Driver itself does not support extended stats, but
+* still have basic stats.
+*/
+   cnt_used_entries = 0;
+
+   for (idx = 0; idx < RTE_NB_STATS; idx++) {
+   xstats_names[cnt_used_entries].id = cnt_used_entries;
+   snprintf(xstats_names[cnt_used_entries].name,
+   sizeof(xstats_names[0].name),
+   "%s", rte_stats_strings[idx].name);
+   cnt_used_entries++;
+   }
+   for (id_queue = 0; id_queue < dev->data->nb_rx_queues; id_queue++) {
+   for (idx = 0; idx < RTE_NB_RXQ_STATS; idx++) {
+

[dpdk-dev] [PATCH v5 0/7] Remove string operations from xstats

2016-06-15 Thread 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 patchset changes the API for
xstats to use integer identifiers instead of strings and implements
this new API for the ixgbe, i40e, e1000, fm10k, and virtio drivers.

--

v5 changes:
* Missing .map file change added (broke shared builds)
* rte_eth_xstats_get_names(): Changed buffer-too-small return value
* Missing commit description added
* Documentation patch squashed (had been ACK'd)

v4 changes:
* rte_eth_xstats_count() removed
* rte_eth_xstats_names() changed to rte_eth_xstats_get_names()
* struct rte_eth_xstats_name renamed to rte_eth_xstat_name
* struct rte_eth_xstats renamed to rte_eth_xstat
* struct rte_eth_dev: .xstats_names renamed to .xstats_get_names
* Other minor local variable name changes
* Documentation updates due to renames
* API changeover patches squashed

v3 changes:
* Corrected ixgbe vf xstats fetching
* Added xstats changes to e1000, f10k, and virtio drivers
* Added cleanup patch that removes now-redundant name field
* Removed ethtool xstats command 
* Removed unused .xstats_count from eth-dev_ops
* Changed test-pmd & proc_info to use new API
* Added documentation update
* Added missing changes to .map file (affected shared lib builds)

v2 changes:
* Fetching xstats count now seperate API function
* Added #define constants for some magic numbers
* Fixed bug with virtual function count fetching
* For non-xstats-supporting drivers, queue stats returned
* Some refactoring/cleanups
* Removed index assumption from example

Remy Horton (7):
  rte: change xstats to use integer ids
  drivers/net/ixgbe: change xstats to use integer ids
  drivers/net/e1000: change xstats to use integer ids
  drivers/net/fm10k: change xstats to use integer ids
  drivers/net/i40e: change xstats to use integer ids
  drivers/net/virtio: change xstats to use integer ids
  rte: change xstats usage to new API

 app/proc_info/main.c|  29 +++--
 app/test-pmd/config.c   |  54 
 doc/guides/prog_guide/poll_mode_drv.rst |  25 ++--
 drivers/net/e1000/igb_ethdev.c  |  58 ++---
 drivers/net/fm10k/fm10k_ethdev.c|  54 +---
 drivers/net/i40e/i40e_ethdev.c  |  82 +++-
 drivers/net/i40e/i40e_ethdev_vf.c   |  29 +++--
 drivers/net/ixgbe/ixgbe_ethdev.c| 106 ++--
 drivers/net/virtio/virtio_ethdev.c  |  64 ---
 lib/librte_ether/rte_ethdev.c   |  92 ---
 lib/librte_ether/rte_ethdev.h   |  48 +--
 lib/librte_ether/rte_ether_version.map  |   6 ++
 12 files changed, 546 insertions(+), 101 deletions(-)

-- 
2.5.5



[dpdk-dev] [PATCH] eal: fix rte_memcpy perf in hsw/bdw

2016-06-15 Thread Thomas Monjalon
2016-05-24 21:23, Zhihong Wang:
> This patch fixes rte_memcpy performance in Haswell and Broadwell for
> vhost when copy size larger than 256 bytes.
> 
> It is observed that for large copies like 1024/1518 ones, rte_memcpy
> suffers high ratio of store buffer full issue which causes pipeline
> to stall in scenarios like vhost enqueue. This can be alleviated by
> adjusting instruction layout. Note that this issue may not be visible
> in micro test.
> 
> How to reproduce?
> 
> PHY-VM-PHY using vhost/virtio or vhost/virtio loop back, with large
> packets like 1024/1518 bytes ones. Make sure packet generation rate
> is not the bottleneck if PHY-VM-PHY is used.
> 
> Signed-off-by: Zhihong Wang 

Test report: http://dpdk.org/ml/archives/dev/2016-May/039716.html

Applied, thanks


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

2016-06-15 Thread Olivier MATZ


On 06/15/2016 04:02 PM, Hunt, David wrote:
>
>
> On 15/6/2016 2:50 PM, Olivier MATZ wrote:
>> Hi David,
>>
>> On 06/15/2016 02:38 PM, Hunt, David wrote:
>>>
>>>
>>> On 15/6/2016 1:03 PM, Olivier MATZ wrote:
 Hi,

 On 06/15/2016 01:47 PM, Hunt, David wrote:
>
>
> On 15/6/2016 11:13 AM, Jan Viktorin wrote:
>> Hi,
>>
>> I've got one last question. Initially, I was interested in creating
>> my own external memory provider based on a Linux Kernel driver.
>> So, I've got an opened file descriptor that points to a device which
>> can mmap a memory regions for me.
>>
>> ...
>> int fd = open("/dev/uio0" ...);
>> ...
>> rte_mempool *pool = rte_mempool_create_empty(...);
>> rte_mempool_set_ops_byname(pool, "uio_allocator_ops");
>>
>> I am not sure how to pass the file descriptor pointer. I thought it
>> would
>> be possible by the rte_mempool_alloc but it's not... Is it possible
>> to solve this case?
>>
>> The allocator is device-specific.
>>
>> Regards
>> Jan
>
> This particular use case is not covered.
>
> We did discuss this before, and an opaque pointer was proposed, but
> did
> not make it in.
> http://article.gmane.org/gmane.comp.networking.dpdk.devel/39821
> (and following emails in that thread)
>
> So, the options for this use case are as follows:
> 1. Use the pool_data to pass data in to the alloc, then set the
> pool_data pointer before coming back from alloc. (It's a bit of a
> hack,
> but means no code change).
> 2. Add an extra parameter to the alloc function. The simplest way I
> can
> think of doing this is to
> take the *opaque passed into rte_mempool_populate_phys, and pass it on
> into the alloc function.
> This will have minimal impact on the public API,s as there is
> already an
> opaque there in the _populate_ funcs, we're just
> reusing it for the alloc.
>
> Do others think option 2 is OK to add this at this late stage? Even if
> the patch set has already been ACK'd?

 Jan's use-case looks to be relevant.

 What about changing:

   rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name)

 into:

  rte_mempool_set_ops(struct rte_mempool *mp, const char *name,
 void *opaque)

 ?

 The opaque pointer would be saved in mempool structure, and used
 when the mempool is populated (calling mempool_ops_alloc).
 The type of the structure pointed by the opaque has to be defined
 (and documented) into each mempool_ops manager.

>>>
>>> Yes, that was another option, which has the additional impact of
>>> needing an
>>> opaque added to the mempool struct. If we use the opaque from the
>>> _populate_
>>> function, we use it straight away in the alloc, no storage needed.
>>>
>>> Also, do you think we need to go ahead with this change, or can we add
>>> it later as an
>>> improvement?
>>
>> The opaque in populate_phys() is already used for something else
>> (i.e. the argument for the free callback of the memory chunk).
>> I'm afraid it could cause confusion to have it used for 2 different
>> things.
>>
>> About the change, I think it could be good to have it in 16.11,
>> because it will probably change the API, and we should avoid to
>> change it each version ;)
>>
>> So I'd vote to have it in the patchset for consistency.
>
> Sure, we should avoid breaking API just after we created it. :)
>
> OK, here's a slightly different proposal.
>
> If we add a string, to the _ops_byname, yes, that will work for Jan's case.
> However, if we add a void*, that allow us the flexibility of passing
> anything we
> want. We can then store the void* in the mempool struct as void
> *pool_config,
> so that when the alloc gets called, it can access whatever is stored at
> *pool_config
> and do the correct initialisation/allocation. In Jan's use case, this
> can simply be typecast
> to a string. In future cases, it can be a struct, which could including
> new flags.

Yep, agree. But not sure I'm seeing the difference with what I
proposed.

>
> I think that change is minimal enough to be low risk at this stage.
>
> Thoughts?

Agree. Thanks!


Olivier


[dpdk-dev] random pkt generator PMD

2016-06-15 Thread Yerden Zhumabekov
On 15.06.2016 15:49, Bruce Richardson wrote:
> On Wed, Jun 15, 2016 at 03:43:56PM +0600, Yerden Zhumabekov wrote:
>> Hello everybody,
>>
>> DPDK already got a number of PMDs for various eth devices, it even has PMD
>> emulations for backends such as pcap, sw rings etc.
>>
>> I've been thinking about the idea of having PMD which would generate mbufs
>> on the fly in some randomized fashion. This would serve goals like, for
>> example:
>>
>> 1) running tests for applications with network processing capabilities
>> without additional software packet generators;
>> 2) making performance measurements with no hw inteference;
>> 3) ability to run without root privileges, --no-pci, --no-huge, for CI
>> build, so on.
>>
>> Maybe there's no such need, and these goals may be achieved by other means
>> and this idea is flawed? Any thoughts?
> Isn't some of this already covered by the NULL PMD? Perhaps it could be 
> extended
> or enhanced to meet some more of your requirements?
>
> /Bruce
Right, but development of various features regarding L3/L4 etc requires 
more subtle approach, like live packets, different protocol versions, 
fields manipulation. In this case some packet mangling/randomizing 
capabilities would be quite useful. Something similar to what is done in 
Pktgen, but more lightweight approach, in a same app.

I've almost made my mind :) so the next question: is there any guide on 
PMD dev? I'm looking through rte_ether.h right now, but some doc would 
be very nice.


[dpdk-dev] [PATCH] app/test: remove rte_pci_dev_ids.h from pci_autotest

2016-06-15 Thread Thomas Monjalon
2016-06-15 11:51, Jan Viktorin:
> On Tue, 14 Jun 2016 16:08:42 +0200
> Thomas Monjalon  wrote:
> 
> > 2016-06-14 15:46, Jan Viktorin:
> > > There are 2 new fake devices for testing PCI infra. All the fake devices
> 
> s/All the fake/All 3 fake/
> 
> > > are now identified by non-existing vendor and device IDs so there is no
> > > real driver to bind to them. The testing drivers match those IDs.  
> > 
> > Why not removing the existing sysfs entries faking real devices?
> 
> There is no reason to remove anything. All 3 devices are fakes. The original
> one was changed to have fake IDs.
> 
> Is it more clear now?

Got it.

Applied, thanks


[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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 v12 0/3] mempool: add external mempool manager

2016-06-15 Thread Olivier MATZ
Hi David,

On 06/15/2016 02:38 PM, Hunt, David wrote:
>
>
> On 15/6/2016 1:03 PM, Olivier MATZ wrote:
>> Hi,
>>
>> On 06/15/2016 01:47 PM, Hunt, David wrote:
>>>
>>>
>>> On 15/6/2016 11:13 AM, Jan Viktorin wrote:
 Hi,

 I've got one last question. Initially, I was interested in creating
 my own external memory provider based on a Linux Kernel driver.
 So, I've got an opened file descriptor that points to a device which
 can mmap a memory regions for me.

 ...
 int fd = open("/dev/uio0" ...);
 ...
 rte_mempool *pool = rte_mempool_create_empty(...);
 rte_mempool_set_ops_byname(pool, "uio_allocator_ops");

 I am not sure how to pass the file descriptor pointer. I thought it
 would
 be possible by the rte_mempool_alloc but it's not... Is it possible
 to solve this case?

 The allocator is device-specific.

 Regards
 Jan
>>>
>>> This particular use case is not covered.
>>>
>>> We did discuss this before, and an opaque pointer was proposed, but did
>>> not make it in.
>>> http://article.gmane.org/gmane.comp.networking.dpdk.devel/39821
>>> (and following emails in that thread)
>>>
>>> So, the options for this use case are as follows:
>>> 1. Use the pool_data to pass data in to the alloc, then set the
>>> pool_data pointer before coming back from alloc. (It's a bit of a hack,
>>> but means no code change).
>>> 2. Add an extra parameter to the alloc function. The simplest way I can
>>> think of doing this is to
>>> take the *opaque passed into rte_mempool_populate_phys, and pass it on
>>> into the alloc function.
>>> This will have minimal impact on the public API,s as there is already an
>>> opaque there in the _populate_ funcs, we're just
>>> reusing it for the alloc.
>>>
>>> Do others think option 2 is OK to add this at this late stage? Even if
>>> the patch set has already been ACK'd?
>>
>> Jan's use-case looks to be relevant.
>>
>> What about changing:
>>
>>   rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name)
>>
>> into:
>>
>>  rte_mempool_set_ops(struct rte_mempool *mp, const char *name,
>> void *opaque)
>>
>> ?
>>
>> The opaque pointer would be saved in mempool structure, and used
>> when the mempool is populated (calling mempool_ops_alloc).
>> The type of the structure pointed by the opaque has to be defined
>> (and documented) into each mempool_ops manager.
>>
>
> Yes, that was another option, which has the additional impact of needing an
> opaque added to the mempool struct. If we use the opaque from the
> _populate_
> function, we use it straight away in the alloc, no storage needed.
>
> Also, do you think we need to go ahead with this change, or can we add
> it later as an
> improvement?

The opaque in populate_phys() is already used for something else
(i.e. the argument for the free callback of the memory chunk).
I'm afraid it could cause confusion to have it used for 2 different
things.

About the change, I think it could be good to have it in 16.11,
because it will probably change the API, and we should avoid to
change it each version ;)

So I'd vote to have it in the patchset for consistency.


Olivier


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

2016-06-15 Thread Thomas Monjalon
I agree this patch do not bring a new issue.
But the current status deserves to be discussed.

2016-06-15 09:54, Ananyev, Konstantin:
> It is safe to add/remove RX/TX callbacks while 
> another thread is doing simultaneously RX/TX burst over same queue.

You are probably right, but I don't why it is safe? On which CPU?
How can we be sure that read and write of the "next" pointer are atomic?


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

2016-06-15 Thread Mcnamara, John

> -Original Message-
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Wednesday, June 15, 2016 10:33 AM
> To: Mcnamara, John 
> Cc: Pattan, Reshma ; dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v9 5/8] pdump: add new library for packet
> capturing support
>
> > 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.
> 
> I understand your concern.
> But you cannot assume every doc changes will be properly highlighted in
> the headline. I think you need to filter patches based on a content
> pattern:
>   +++ b/doc/guides/

Hi Thomas,

That still leaves the issue of not being able to ack the doc part of the patch
separately from the rest of the patch.

John




[dpdk-dev] random pkt generator PMD

2016-06-15 Thread Yerden Zhumabekov
Hello everybody,

DPDK already got a number of PMDs for various eth devices, it even has 
PMD emulations for backends such as pcap, sw rings etc.

I've been thinking about the idea of having PMD which would generate 
mbufs on the fly in some randomized fashion. This would serve goals 
like, for example:

1) running tests for applications with network processing capabilities 
without additional software packet generators;
2) making performance measurements with no hw inteference;
3) ability to run without root privileges, --no-pci, --no-huge, for CI 
build, so on.

Maybe there's no such need, and these goals may be achieved by other 
means and this idea is flawed? Any thoughts?


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

2016-06-15 Thread Bruce Richardson
On Wed, Jun 15, 2016 at 12:36:15AM +0530, Jerin Jacob wrote:
> 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
> 
Hi Jerin,

hopefully a final set of comments before merge on this set, as it's looking
very good now.

* Two patches look like they need to be split, as they are combining multiple
  functions into one patch. They are:
[dpdk-dev,v5,16/25] net/thunderx: add MTU set and promiscuous enable support
[dpdk-dev,v5,20/25] net/thunderx: implement supported ptype get and Rx 
queue count
  For the other patches which add multiple functions, the functions seem to be
  logically related so I don't think there is a problem

* check-git-logs.sh is warning about a few of the commit messages being too 
long.
  Splitting patch 20 should fix one of those, but there are a few remaining.
  A number of titles refer to ThunderX in the message, but this is probably
  unnecessary, as the prefix already contains "net/thunderx" in it.

Regards,
/Bruce

PS: Please also baseline patches on dpdk-next-net/rel_16_07 tree. They currently
apply fine to that tree so there is no problem, but just in case later commits
break things, that is the tree that net patches should be based on.


[dpdk-dev] [PATCH] config: thunderx: select maximum supported numa nodes and lcores

2016-06-15 Thread Thomas Monjalon
2016-06-13 19:31, Jerin Jacob:
> ThunderX platform can support dual sockets numa configuration and 48
> cores per socket.
> 
> Signed-off-by: Jerin Jacob 

Applied, thanks


[dpdk-dev] random pkt generator PMD

2016-06-15 Thread Panu Matilainen
On 06/15/2016 03:14 PM, Yerden Zhumabekov wrote:
>
>
> On 15.06.2016 17:25, Panu Matilainen wrote:
>> On 06/15/2016 02:10 PM, Yerden Zhumabekov wrote:
>>>
>>>
>>> On 15.06.2016 16:43, Dumitrescu, Cristian wrote:

>
> Hello everybody,
>
> DPDK already got a number of PMDs for various eth devices, it even has
> PMD emulations for backends such as pcap, sw rings etc.
>
> I've been thinking about the idea of having PMD which would generate
> mbufs on the fly in some randomized fashion. This would serve goals
> like, for example:
>
> 1) running tests for applications with network processing capabilities
> without additional software packet generators;
> 2) making performance measurements with no hw inteference;
> 3) ability to run without root privileges, --no-pci, --no-huge, for CI
> build, so on.
>
> Maybe there's no such need, and these goals may be achieved by other
> means and this idea is flawed? Any thoughts?
 How about a Perl/Python script to generate a PCAP file with random
 packets and then feed the PCAP file to the PCAP PMD?

 Random can mean different requirements for different
 users/application, I think it is difficult to fit this  under a simple
 generic API. Customizing the script for different requirements if a
 far better option in my opinion.
>>>
>>> AFAIK, the thing about pcap pmd is that one needs to rewind pcap file
>>> once pcap pmd reaches its end. It requires additional (non-generic)
>>> handling in app code.
>>
>> So add a loop-mode to pcap pmd?
>
> It would be nice to have an option like "...,rewind=1,...".

As Cristian points out in 
http://dpdk.org/ml/archives/dev/2016-June/041589.html, the current pmd 
behavior of stopping is the odd man out in the pmd crowd.

Rather than whether to rewind or not, I'd make the number of loops 
configurable, defaulting to forever and 1 being the equal to current 
behavior.

- Panu -


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

2016-06-15 Thread Bruce Richardson
On Wed, Jun 15, 2016 at 03:20:27PM +0100, Ananyev, Konstantin wrote:
> 
> 
> > -Original Message-
> > From: Ivan Boule [mailto:ivan.boule at 6wind.com]
> > Sent: Wednesday, June 15, 2016 3:07 PM
> > To: Richardson, Bruce; Ananyev, Konstantin
> > Cc: Thomas Monjalon; Pattan, Reshma; dev at dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx 
> > callback lists
> > 
> > On 06/15/2016 03:29 PM, Bruce Richardson wrote:
> > > On Wed, Jun 15, 2016 at 12:40:16PM +, Ananyev, Konstantin wrote:
> > >> Hi Ivan,
> > >>
> > >>> -Original Message-
> > >>> From: Ivan Boule [mailto:ivan.boule at 6wind.com]
> > >>> Sent: Wednesday, June 15, 2016 1:15 PM
> > >>> To: Thomas Monjalon; Ananyev, Konstantin
> > >>> Cc: Pattan, Reshma; dev at dpdk.org
> > >>> Subject: Re: [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect 
> > >>> Rx/Tx callback lists
> > >>>
> > >>> On 06/15/2016 10:48 AM, Thomas Monjalon wrote:
> > >>>
> > >
> > >> 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.
> > 
> > >>>
> > >>> Hi Reshma,
> > >>>
> > >>> You claim that the "rte_eth_rx_cb_lock" does not need to be hold in the
> > >>> function "rte_eth_rx_burst()" while parsing the "post_rx_burst_cbs" list
> > >>> of RX callbacks associated with the polled RX queue to safely remove RX
> > >>> callback(s) in parallel.
> > >>> The problem is not [only] with the setting and the loading of "cb->next"
> > >>> that you assume to be atomic operations, which is certainly true on most
> > >>> CPUs.
> > >>> I see the 2 important following issues:
> > >>>
> > >>> 1) the "rte_eth_rxtx_callback" data structure associated with a removed
> > >>> RX callback could still be accessed in the callback parsing loop of the
> > >>> function "rte_eth_rx_burst()" after having been freed in parallel.
> > >>>
> > >>> BUT SUCH A BAD SITUATION WILL NOT CURRENTLY HAPPEN, THANKS TO THE NICE
> > >>> MEMORY LEAK BUG in the function "rte_eth_remove_rx_callback()"  that
> > >>> does not free the "rte_eth_rxtx_callback" data structure associated with
> > >>> the removed callback !
> > >>
> > >> Yes, though it is documented behaviour, someone can probably
> > >> refer it as a feature, not a bug ;)
> > >>
> > >
> > > +1
> > > This is definitely not a bug, this is absolutely by design. One may argue 
> > > with
> > > the design, but it was done for a definite reason, so as to avoid paying 
> > > the
> > > penalty of having locks. It pushes more responsibility onto the app, but 
> > > it
> > > does allow the app to choose the best solution for managing the freeing of
> > > memory for its situation. The alternative is to force all apps to pay the 
> > > cost
> > > of having locks, even if better options for freeing the memory are 
> > > available.
> > >
> > > /Bruce
> > >
> > 
> > -1 (not to say 0x)
> > 
> > This is definitely an API design bug !
> > I would say that if you don't know how to free a resource that you
> > allocate, it is very likely that you are wrong allocating it.
> > And this is exactly what happens here with RX/TX callback data structures.
> > This problem can easily be addressed by just changing the API as follows:
> > 
> > Change
> >  void *
> >  rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
> >  rte_rx_callback_fn fn, void *user_param)
> > 
> > to
> >  int
> >  rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
> >  struct rte_eth_rxtx_callback *cb)
> > 
> > In addition of solving the problem, this approach makes the API
> > consistent and let the application allocate "rte_eth_rxtx_callback" data
> > structures through any appropriate mean.
> 
> That might make API a bit cleaner, but I don't see how it fixes the generic 
> problem:
> there is still no way to know by the upper layer when it is safe to 
> free/re-use
> removed callback, but to make sure that all IO on that queue is stopped
> (I.E. some external synchronisation around the queue).   

Actually, it allows other, more creative solutions, like an app having a
statically allocated set/pool of callback structures that it doesn't need to
allocate or free at all.

/Bruce



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

2016-06-15 Thread Bruce Richardson
On Wed, Jun 15, 2016 at 04:07:20PM +0200, Ivan Boule wrote:
> On 06/15/2016 03:29 PM, Bruce Richardson wrote:
> >On Wed, Jun 15, 2016 at 12:40:16PM +, Ananyev, Konstantin wrote:
> >>Hi Ivan,
> >>
> >>>-Original Message-
> >>>From: Ivan Boule [mailto:ivan.boule at 6wind.com]
> >>>Sent: Wednesday, June 15, 2016 1:15 PM
> >>>To: Thomas Monjalon; Ananyev, Konstantin
> >>>Cc: Pattan, Reshma; dev at dpdk.org
> >>>Subject: Re: [dpdk-dev] [PATCH v9 1/8] ethdev: use locks to protect Rx/Tx 
> >>>callback lists
> >>>
> >>>On 06/15/2016 10:48 AM, Thomas Monjalon wrote:
> >>>
> >
> >>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.
> 
> >>>
> >>>Hi Reshma,
> >>>
> >>>You claim that the "rte_eth_rx_cb_lock" does not need to be hold in the
> >>>function "rte_eth_rx_burst()" while parsing the "post_rx_burst_cbs" list
> >>>of RX callbacks associated with the polled RX queue to safely remove RX
> >>>callback(s) in parallel.
> >>>The problem is not [only] with the setting and the loading of "cb->next"
> >>>that you assume to be atomic operations, which is certainly true on most
> >>>CPUs.
> >>>I see the 2 important following issues:
> >>>
> >>>1) the "rte_eth_rxtx_callback" data structure associated with a removed
> >>>RX callback could still be accessed in the callback parsing loop of the
> >>>function "rte_eth_rx_burst()" after having been freed in parallel.
> >>>
> >>>BUT SUCH A BAD SITUATION WILL NOT CURRENTLY HAPPEN, THANKS TO THE NICE
> >>>MEMORY LEAK BUG in the function "rte_eth_remove_rx_callback()"  that
> >>>does not free the "rte_eth_rxtx_callback" data structure associated with
> >>>the removed callback !
> >>
> >>Yes, though it is documented behaviour, someone can probably
> >>refer it as a feature, not a bug ;)
> >>
> >
> >+1
> >This is definitely not a bug, this is absolutely by design. One may argue 
> >with
> >the design, but it was done for a definite reason, so as to avoid paying the
> >penalty of having locks. It pushes more responsibility onto the app, but it
> >does allow the app to choose the best solution for managing the freeing of
> >memory for its situation. The alternative is to force all apps to pay the 
> >cost
> >of having locks, even if better options for freeing the memory are available.
> >
> >/Bruce
> >
> 
> -1 (not to say 0x)
> 
> This is definitely an API design bug !
> I would say that if you don't know how to free a resource that you allocate,
> it is very likely that you are wrong allocating it.
> And this is exactly what happens here with RX/TX callback data structures.
> This problem can easily be addressed by just changing the API as follows:
> 
> Change
> void *
> rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
> rte_rx_callback_fn fn, void *user_param)
> 
> to
> int
> rte_eth_add_rx_callback(uint8_t port_id, uint16_t queue_id,
> struct rte_eth_rxtx_callback *cb)
> 
> In addition of solving the problem, this approach makes the API consistent
> and let the application allocate "rte_eth_rxtx_callback" data structures
> through any appropriate mean.
> 

That looks like a reasonable change to me. It keeps the important part of the
existing API behaviour, while making the API more consistent.

/Bruce


[dpdk-dev] [PATCH] mk: define objcopy target and arch on IBM POWER

2016-06-15 Thread Thomas Monjalon
2016-06-15 19:38, Chao Zhu:
> This patch defines the target and arch value of objcopy program for
> IBM POWER PPC64 little endian architecture. This is a fix of the
> original patch proposed by Jan Viktorin .
> 
> Signed-off-by: Chao Zhu 

Fixes: 99d6231fdca7 ("mk: define objcopy-specific target and arch")

Applied, thanks


[dpdk-dev] [PATCH v2 4/4] app: add new TEST_HEXDUMP macro

2016-06-15 Thread Pablo de Lara
Instead of using the previous RTE_APP_TEST_DEBUG macro,
to dump memory when it was enabled (with rte_hexdump),
a new TEST_HEXDUMP is defined, which will call rte_hexdump
if RTE_LOG_LEVEL is set to RTE_LOG_DEBUG.

Signed-off-by: Pablo de Lara 
---
 app/test/test.h   |   7 +++
 app/test/test_cryptodev.c | 142 --
 app/test/test_cryptodev_aes.c |   6 +-
 3 files changed, 62 insertions(+), 93 deletions(-)

diff --git a/app/test/test.h b/app/test/test.h
index a2fba60..8ddde23 100644
--- a/app/test/test.h
+++ b/app/test/test.h
@@ -35,6 +35,7 @@
 #define _TEST_H_
 #include 
 #include 
+#include "rte_log.h"

 #define TEST_SUCCESS  (0)
 #define TEST_FAILED  (-1)
@@ -150,6 +151,12 @@ struct unit_test_case {

 #define TEST_CASES_END() { NULL, NULL, NULL, NULL, NULL, 0 }

+#if RTE_LOG_LEVEL >= RTE_LOG_DEBUG
+#define TEST_HEXDUMP(file, title, buf, len) rte_hexdump(file, title, buf, len)
+#else
+#define TEST_HEXDUMP(file, title, buf, len) do {} while (0)
+#endif
+
 struct unit_test_suite {
const char *suite_name;
int (*setup)(void);
diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index a5b34e2..1acb324 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -1075,9 +1075,9 @@ create_snow3g_hash_session(uint8_t dev_id,
struct crypto_unittest_params *ut_params = _params;

memcpy(hash_key, key, key_len);
-#ifdef RTE_APP_TEST_DEBUG
-   rte_hexdump(stdout, "key:", key, key_len);
-#endif
+
+   TEST_HEXDUMP(stdout, "key:", key, key_len);
+
/* Setup Authentication Parameters */
ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
ut_params->auth_xform.next = NULL;
@@ -1113,9 +1113,8 @@ create_snow3g_cipher_session(uint8_t dev_id,
ut_params->cipher_xform.cipher.key.data = cipher_key;
ut_params->cipher_xform.cipher.key.length = key_len;

-#ifdef RTE_APP_TEST_DEBUG
-   rte_hexdump(stdout, "key:", key, key_len);
-#endif
+   TEST_HEXDUMP(stdout, "key:", key, key_len);
+
/* Create Crypto session */
ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
_params->
@@ -1239,9 +1238,8 @@ create_snow3g_cipher_auth_session(uint8_t dev_id,
ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
ut_params->cipher_xform.cipher.key.length = key_len;

-#ifdef RTE_APP_TEST_DEBUG
-   rte_hexdump(stdout, "key:", key, key_len);
-#endif
+   TEST_HEXDUMP(stdout, "key:", key, key_len);
+
/* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
_params->cipher_xform);
@@ -1281,9 +1279,8 @@ create_snow3g_auth_cipher_session(uint8_t dev_id,
ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
ut_params->cipher_xform.cipher.key.length = key_len;

-#ifdef RTE_APP_TEST_DEBUG
-   rte_hexdump(stdout, "key:", key, key_len);
-#endif
+   TEST_HEXDUMP(stdout, "key:", key, key_len);
+
/* Create Crypto session*/
ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
_params->auth_xform);
@@ -1341,10 +1338,8 @@ create_snow3g_hash_operation(const uint8_t *auth_tag,
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);

-#ifdef RTE_APP_TEST_DEBUG
-   rte_hexdump(stdout, "aad:",
+   TEST_HEXDUMP(stdout, "aad:",
sym_op->auth.aad.data, aad_len);
-#endif

/* digest */
sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
@@ -1361,11 +1356,9 @@ create_snow3g_hash_operation(const uint8_t *auth_tag,
else
rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);

-#ifdef RTE_APP_TEST_DEBUG
-   rte_hexdump(stdout, "digest:",
+   TEST_HEXDUMP(stdout, "digest:",
sym_op->auth.digest.data,
sym_op->auth.digest.length);
-#endif

sym_op->auth.data.length = auth_len;
sym_op->auth.data.offset = auth_offset;
@@ -1440,10 +1433,8 @@ create_snow3g_cipher_hash_operation(const uint8_t 
*auth_tag,
memset(sym_op->auth.aad.data, 0, aad_buffer_len);
rte_memcpy(sym_op->auth.aad.data, aad, aad_len);

-#ifdef RTE_APP_TEST_DEBUG
-   rte_hexdump(stdout, "aad:",
+   TEST_HEXDUMP(stdout, "aad:",
sym_op->auth.aad.data, aad_len);
-#endif

/* digest */
sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
@@ -1460,11 +1451,9 @@ create_snow3g_cipher_hash_operation(const uint8_t 
*auth_tag,
else
rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);

-   #ifdef RTE_APP_TEST_DEBUG
-   rte_hexdump(stdout, "digest:",
+   TEST_HEXDUMP(stdout, "digest:",
sym_op->auth.digest.data,
sym_op->auth.digest.length);
-   #endif


[dpdk-dev] [PATCH v2 1/4] test: remove useless hexdump include

2016-06-15 Thread Pablo de Lara
Cryptodev performance tests do not need to use any function
from rte_hexdump.h.

Fixes: 202d375c60bc1 ("app/test: add cryptodev unit and performance tests")

Signed-off-by: Pablo de Lara 
---
 app/test/test_cryptodev_perf.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/app/test/test_cryptodev_perf.c b/app/test/test_cryptodev_perf.c
index b3f4fd9..151078f 100644
--- a/app/test/test_cryptodev_perf.c
+++ b/app/test/test_cryptodev_perf.c
@@ -38,7 +38,6 @@
 #include 
 #include 
 #include 
-#include 

 #include "test.h"
 #include "test_cryptodev.h"
-- 
2.5.0



  1   2   3   >