[dpdk-dev] [PATCH v3 00/11] Port XStats

2015-10-29 Thread Stephen Hemminger
On Wed, 28 Oct 2015 17:35:09 +
Tom Crugnale  wrote:

> Hi Harry,
> 
> We are planning on using the xstats API for periodic stats collection through 
> a polling thread.  This would be done in a generic NIC agnostic manner, which 
> would require that the xstats identifiers have consistent naming amongst all 
> of the NIC types.  It would likely be polled several times per second and 
> would only gather a subset of all available xstats types.  
> 
> I have reviewed your patches and am interested in providing some API 
> enhancements and bugfixes.  Are you willing to provide feedback on such 
> changes?
> 
> Thank you,
> Tom

The whole point of xstats is to allow device specific statistics.
Consistent use of names is good from a user interface point of view, but 
probably
not a hard requirement.



[dpdk-dev] [PATCH v5 0/7] Support new flow director modes on Intel x550 NIC

2015-10-29 Thread Thomas Monjalon
> > Wenzhuo Lu (7):
> >   lib/librte_ether: modify the structures for fdir new modes
> >   app/testpmd: initialize the new fields for fdir mask
> >   app/testpmd: new fdir modes for testpmd parameter
> >   app/testpmd: modify the output of the CLI show port fdir
> >   app/testpmd: modify and add fdir filter and mask CLIs for new modes
> >   ixgbe: implementation for fdir new modes' config
> >   doc: release notes update for flow director enhancement
> 
> Acked-by: Konstantin Ananyev 

Applied, thanks


[dpdk-dev] [PATCH v3 00/11] Port XStats

2015-10-29 Thread Tom Crugnale
I understand.  Is this the reason that that strings were used to identify the 
xstat types?  An enum type would be much more efficient instead of doing string 
copies when retrieving the stats, but the number of enum entries would quickly 
grow out of control as device specific stats were added.

In this case, I'm actually referring to the stats that are common to all NICs.  
For example, for the received fragmented packets counter, there are three 
strings that identify this value: rx_fragment_packets (igb), rx_fragment_errors 
(ixgbe), rx_fragmented_packets (i40e).
I was thinking of making those names consistent.  Perhaps the reason why they 
were different in the first place is that each of the device datasheets refers 
to these exact names.

Tom

-Original Message-
From: Stephen Hemminger [mailto:step...@networkplumber.org] 
Sent: Wednesday, October 28, 2015 5:32 PM
To: Tom Crugnale
Cc: Harry van Haaren; dev at dpdk.org
Subject: Re: [dpdk-dev] [PATCH v3 00/11] Port XStats

On Wed, 28 Oct 2015 17:35:09 +
Tom Crugnale  wrote:

> Hi Harry,
> 
> We are planning on using the xstats API for periodic stats collection through 
> a polling thread.  This would be done in a generic NIC agnostic manner, which 
> would require that the xstats identifiers have consistent naming amongst all 
> of the NIC types.  It would likely be polled several times per second and 
> would only gather a subset of all available xstats types.  
> 
> I have reviewed your patches and am interested in providing some API 
> enhancements and bugfixes.  Are you willing to provide feedback on such 
> changes?
> 
> Thank you,
> Tom

The whole point of xstats is to allow device specific statistics.
Consistent use of names is good from a user interface point of view, but 
probably not a hard requirement.



[dpdk-dev] [PATCH v1] i40e: Fix the statistics issue of i40e

2015-10-29 Thread Xutao Sun
The old statistics on i40e only count the packets on ports.
This patch is to make statistics for packets both on ports and VSI.
But there're still some issues about statistics for 'bytes'.

Signed-off-by: Xutao Sun 
---
 drivers/net/i40e/i40e_ethdev.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 40b0526..a8d7116 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1511,21 +1511,26 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)
if (pf->main_vsi)
i40e_update_vsi_stats(pf->main_vsi);

-   stats->ipackets = ns->eth.rx_unicast + ns->eth.rx_multicast +
-   ns->eth.rx_broadcast;
-   stats->opackets = ns->eth.tx_unicast + ns->eth.tx_multicast +
-   ns->eth.tx_broadcast;
+   stats->ipackets = pf->main_vsi->eth_stats.rx_unicast +
+   pf->main_vsi->eth_stats.rx_multicast +
+   pf->main_vsi->eth_stats.rx_broadcast -
+   pf->main_vsi->eth_stats.rx_discards;
+   stats->opackets = pf->main_vsi->eth_stats.tx_unicast +
+   pf->main_vsi->eth_stats.tx_multicast +
+   pf->main_vsi->eth_stats.tx_broadcast;
stats->ibytes   = ns->eth.rx_bytes;
stats->obytes   = ns->eth.tx_bytes;
-   stats->oerrors  = ns->eth.tx_errors;
-   stats->imcasts  = ns->eth.rx_multicast;
+   stats->oerrors  = ns->eth.tx_errors + 
+   pf->main_vsi->eth_stats.tx_errors;
+   stats->imcasts  = pf->main_vsi->eth_stats.rx_multicast;
stats->fdirmatch = ns->fd_sb_match;

/* Rx Errors */
stats->ibadcrc  = ns->crc_errors;
stats->ibadlen  = ns->rx_length_errors + ns->rx_undersize +
ns->rx_oversize + ns->rx_fragments + ns->rx_jabber;
-   stats->imissed  = ns->eth.rx_discards;
+   stats->imissed  = ns->eth.rx_discards + 
+   pf->main_vsi->eth_stats.rx_discards;
stats->ierrors  = stats->ibadcrc + stats->ibadlen + stats->imissed;

PMD_DRV_LOG(DEBUG, "* PF stats start 
***");
-- 
1.9.3



[dpdk-dev] [PATCH] vhost: fix build error on old kernel doesn't support MQ

2015-10-29 Thread Yuanhan Liu
Fix build error:

  virtio-net.c:80:89: error: ?VIRTIO_NET_F_MQ? undeclared here
  rte_virtio_net.h:109: error: ?VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX? undeclared here

Above two virtio-net MQ macros are introduced since kernel v3.8.
For older kernel, we should not reference them directly, hence,
this patch introduced two wrapper macros, with proper values
being set depending on we support MQ or not.

Fixes: 19d4d7ef2a21 ("vhost-user: enable multiple queue")

Reported-by: Gu YongjieX 
Signed-off-by: Yuanhan Liu 
---
 lib/librte_vhost/rte_virtio_net.h| 17 -
 lib/librte_vhost/vhost_user/vhost-net-user.c |  2 +-
 lib/librte_vhost/virtio-net.c|  2 +-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/lib/librte_vhost/rte_virtio_net.h 
b/lib/librte_vhost/rte_virtio_net.h
index 426a70d..b6386f9 100644
--- a/lib/librte_vhost/rte_virtio_net.h
+++ b/lib/librte_vhost/rte_virtio_net.h
@@ -93,6 +93,21 @@ struct vhost_virtqueue {
struct buf_vector   buf_vec[BUF_VECTOR_MAX];/**< for 
scatter RX. */
 } __rte_cache_aligned;

+
+/*
+ * Make an extra wrapper for VIRTIO_NET_F_MQ and
+ * VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX as they are
+ * introduced since kernel v3.8. This makes our
+ * code buildable for older kernel.
+ */
+#ifdef VIRTIO_NET_F_MQ
+ #define VHOST_MAX_QUEUE_PAIRS VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX
+ #define VHOST_SUPPORTS_MQ (1ULL << VIRTIO_NET_F_MQ)
+#else
+ #define VHOST_MAX_QUEUE_PAIRS 1
+ #define VHOST_SUPPORTS_MQ 0
+#endif
+
 /**
  * Device structure contains all configuration information relating to the 
device.
  */
@@ -106,7 +121,7 @@ struct virtio_net {
charifname[IF_NAME_SZ]; /**< Name of the tap 
device or socket path. */
uint32_tvirt_qp_nb; /**< number of queue pair we 
have allocated */
void*priv;  /**< private context */
-   struct vhost_virtqueue  *virtqueue[VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX];
/**< Contains all virtqueue information. */
+   struct vhost_virtqueue  *virtqueue[VHOST_MAX_QUEUE_PAIRS * 2];  /**< 
Contains all virtqueue information. */
 } __rte_cache_aligned;

 /**
diff --git a/lib/librte_vhost/vhost_user/vhost-net-user.c 
b/lib/librte_vhost/vhost_user/vhost-net-user.c
index f681676..2dc0547 100644
--- a/lib/librte_vhost/vhost_user/vhost-net-user.c
+++ b/lib/librte_vhost/vhost_user/vhost-net-user.c
@@ -424,7 +424,7 @@ vserver_message_handler(int connfd, void *dat, int *remove)
break;

case VHOST_USER_GET_QUEUE_NUM:
-   msg.payload.u64 = VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX;
+   msg.payload.u64 = VHOST_MAX_QUEUE_PAIRS;
msg.size = sizeof(msg.payload.u64);
send_vhost_message(connfd, &msg);
break;
diff --git a/lib/librte_vhost/virtio-net.c b/lib/librte_vhost/virtio-net.c
index 97213c5..3e82605 100644
--- a/lib/librte_vhost/virtio-net.c
+++ b/lib/librte_vhost/virtio-net.c
@@ -74,7 +74,7 @@ static struct virtio_net_config_ll *ll_root;
 #define VHOST_SUPPORTED_FEATURES ((1ULL << VIRTIO_NET_F_MRG_RXBUF) | \
(1ULL << VIRTIO_NET_F_CTRL_VQ) | \
(1ULL << VIRTIO_NET_F_CTRL_RX) | \
-   (1ULL << VIRTIO_NET_F_MQ)  | \
+   (VHOST_SUPPORTS_MQ)| \
(1ULL << VHOST_F_LOG_ALL)  | \
(1ULL << VHOST_USER_F_PROTOCOL_FEATURES))
 static uint64_t VHOST_FEATURES = VHOST_SUPPORTED_FEATURES;
-- 
1.9.0



[dpdk-dev] [PATCH v5 0/2] i40e: RSS/FD granularity configuration

2015-10-29 Thread Helin Zhang
The default input set of fields of a received packet are loaded from
firmware, which cannot be modified even users want to use different
fields for RSS or flow director. Here adds more flexibilities of
selecting or adding packet fields for hash calculation or flow
director to users. It also includes the modifications in testpmd to
support the testing.

v2 changes:
Solved the compilation issues.

v3 changes:
Support selecting more input set fields.

v4 changes:
Removed operation of 'delete', as it is not necessary.
Added FD granularity in both pmd and testpmd, as it is similar to
RSS granularity.

v5 changes:
Fixed issue of generating wrong input set for registers on ipv6-udp
and ipv6-tcp pc types.
Added clear masking operations during checking if MASK registers are
opcupied or not.
Reworked several annotations.

Helin Zhang (2):
  i40e: RSS/FD granularity configuration
  app/testpmd: add test commands for RSS/FD granularity

 app/test-pmd/cmdline.c  | 196 +++
 drivers/net/i40e/i40e_ethdev.c  | 742 
 drivers/net/i40e/i40e_ethdev.h  |   7 +
 drivers/net/i40e/i40e_fdir.c|  31 ++
 lib/librte_ether/rte_eth_ctrl.h | 114 +-
 5 files changed, 1086 insertions(+), 4 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH v5 1/2] i40e: RSS/FD granularity configuration

2015-10-29 Thread Helin Zhang
The default input set of fields of a received packet are loaded from
firmware, which cannot be modified even users want to use different
fields for RSS or flow director. Here adds more flexibilities of
selecting packet fields for hash calculation or flow director for
users.

Signed-off-by: Helin Zhang 
Signed-off-by: Andrey Chilikin 
---
 drivers/net/i40e/i40e_ethdev.c  | 742 
 drivers/net/i40e/i40e_ethdev.h  |   7 +
 drivers/net/i40e/i40e_fdir.c|  31 ++
 lib/librte_ether/rte_eth_ctrl.h | 114 +-
 4 files changed, 890 insertions(+), 4 deletions(-)

v2 changes:
Solved the compilation issues.

v3 changes:
Support selecting more input set fields.

v4 changes:
Removed operation of 'delete', as it is not necessary.
Added FD granularity, as it is similar to RSS granularity.

v5 changes:
Fixed issue of generating wrong input set for registers on ipv6-udp
and ipv6-tcp pc types.
Added clear masking operations during checking if MASK registers are
opcupied or not.
Reworked several annotations.

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 478e94d..fb262a5 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -113,6 +113,142 @@
 #define I40E_PRTTSYN_TSYNENA  0x8000
 #define I40E_PRTTSYN_TSYNTYPE 0x0e00

+#define I40E_PRTQF_FD_INSET(_i, _j)  (0x0025 + ((_i) * 64 + (_j) * 32))
+#define I40E_GLQF_FD_MSK(_i, _j) (0x00267200 + ((_i) * 4 + (_j) * 8))
+#define I40E_GLQF_FD_MSK_FIELD   0x
+#define I40E_GLQF_HASH_INSET(_i, _j) (0x00267600 + ((_i) * 4 + (_j) * 8))
+#define I40E_GLQF_HASH_MSK(_i, _j)   (0x00267A00 + ((_i) * 4 + (_j) * 8))
+#define I40E_GLQF_HASH_MSK_FIELD  0x
+
+#define I40E_INSET_NONE0x0ULL
+
+/* bit0 ~ bit 7 */
+#define I40E_INSET_DMAC0x0001ULL
+#define I40E_INSET_SMAC0x0002ULL
+#define I40E_INSET_VLAN_OUTER  0x0004ULL
+#define I40E_INSET_VLAN_INNER  0x0008ULL
+#define I40E_INSET_VLAN_TUNNEL 0x0010ULL
+
+/* bit 8 ~ bit 15 */
+#define I40E_INSET_IPV4_SRC0x0100ULL
+#define I40E_INSET_IPV4_DST0x0200ULL
+#define I40E_INSET_IPV6_SRC0x0400ULL
+#define I40E_INSET_IPV6_DST0x0800ULL
+#define I40E_INSET_SRC_PORT0x1000ULL
+#define I40E_INSET_DST_PORT0x2000ULL
+#define I40E_INSET_SCTP_VT 0x4000ULL
+
+/* bit 16 ~ bit 31 */
+#define I40E_INSET_IPV4_TOS0x0001ULL
+#define I40E_INSET_IPV4_PROTO  0x0002ULL
+#define I40E_INSET_IPV4_TTL0x0004ULL
+#define I40E_INSET_IPV6_TC 0x0008ULL
+#define I40E_INSET_IPV6_FLOW   0x0010ULL
+#define I40E_INSET_IPV6_NEXT_HDR   0x0020ULL
+#define I40E_INSET_IPV6_HOP_LIMIT  0x0040ULL
+#define I40E_INSET_TCP_FLAGS   0x0080ULL
+
+/* bit 32 ~ bit 47, tunnel fields */
+#define I40E_INSET_TUNNEL_IPV4_DST   0x0001ULL
+#define I40E_INSET_TUNNEL_IPV6_DST   0x0002ULL
+#define I40E_INSET_TUNNEL_DMAC   0x0004ULL
+#define I40E_INSET_TUNNEL_SRC_PORT   0x0008ULL
+#define I40E_INSET_TUNNEL_DST_PORT   0x0010ULL
+#define I40E_INSET_TUNNEL_ID 0x0020ULL
+
+/* bit 48 ~ bit 55 */
+#define I40E_INSET_LAST_ETHER_TYPE 0x0001ULL
+
+/* bit 56 ~ bit 63, Flex Payload */
+#define I40E_INSET_FLEX_PAYLOAD_W1 0x0100ULL
+#define I40E_INSET_FLEX_PAYLOAD_W2 0x0200ULL
+#define I40E_INSET_FLEX_PAYLOAD_W3 0x0400ULL
+#define I40E_INSET_FLEX_PAYLOAD_W4 0x0800ULL
+#define I40E_INSET_FLEX_PAYLOAD_W5 0x1000ULL
+#define I40E_INSET_FLEX_PAYLOAD_W6 0x2000ULL
+#define I40E_INSET_FLEX_PAYLOAD_W7 0x4000ULL
+#define I40E_INSET_FLEX_PAYLOAD_W8 0x8000ULL
+#define I40E_INSET_FLEX_PAYLOAD \
+   (I40E_INSET_FLEX_PAYLOAD_W1 | I40E_INSET_FLEX_PAYLOAD_W2 | \
+   I40E_INSET_FLEX_PAYLOAD_W3 | I40E_INSET_FLEX_PAYLOAD_W3 | \
+   I40E_INSET_FLEX_PAYLOAD_W5 | I40E_INSET_FLEX_PAYLOAD_W6 | \
+   I40E_INSET_FLEX_PAYLOAD_W7 | I40E_INSET_FLEX_PAYLOAD_W8)
+
+/**
+ * Below are values for writing un-exposed registers suggested
+ * by silicon experts
+ */
+/* Destination MAC address */
+#define I40E_REG_INSET_L2_DMAC   0xE000ULL
+/* Source MAC address */
+#define I40E_REG_INSET_L2_SMAC   0x1C00ULL
+/* VLAN tag in the outer L2 header */
+#define I40E_REG_INSET_L2_OUTER_VLAN 0x0080ULL
+/* VLAN tag in the inner L2 header */
+#define I40E_REG_INSET_L2_INNER_VLAN 0x0100ULL
+/* Source IPv4 address */
+#define I40E_REG_INSET_L3_SRC_IP40x00018000ULL
+/* Destination IPv4 address */
+#d

[dpdk-dev] [PATCH v5 2/2] app/testpmd: add test commands for RSS/FD granularity

2015-10-29 Thread Helin Zhang
Test commands are added to support selecting input set, or adding
new input set per different pctype.

Signed-off-by: Helin Zhang 
Signed-off-by: Andrey Chilikin 
---
 app/test-pmd/cmdline.c | 196 +
 1 file changed, 196 insertions(+)

v3 changes:
Support selecting more input set fields.

v4 changes:
Removed operation of 'delete'.
Added test commands for FD granularity.

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b3c36f3..7b7143b 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -9111,6 +9111,200 @@ cmdline_parse_inst_t cmd_set_hash_global_config = {
},
 };

+/* Set hash input set */
+struct cmd_set_hash_input_set_result {
+   cmdline_fixed_string_t set_hash_input_set;
+   uint8_t port_id;
+   cmdline_fixed_string_t flow_type;
+   cmdline_fixed_string_t inset_field;
+   cmdline_fixed_string_t select;
+};
+
+static enum rte_eth_input_set_field
+str2inset(char *string)
+{
+   uint16_t i;
+
+   static const struct {
+   char str[32];
+   enum rte_eth_input_set_field inset;
+   } inset_table[] = {
+   {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
+   {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
+   {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
+   {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
+   {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
+   {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
+   {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
+   {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
+   {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
+   {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
+   {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
+   {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
+   {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
+   {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
+   {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
+   {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
+   {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
+   {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
+   {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
+   {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
+   {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
+   {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
+   {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
+   {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
+   {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
+   {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
+   {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
+   {"none", RTE_ETH_INPUT_SET_NONE},
+   };
+
+   for (i = 0; i < RTE_DIM(inset_table); i++) {
+   if (!strcmp(string, inset_table[i].str))
+   return inset_table[i].inset;
+   }
+
+   return RTE_ETH_INPUT_SET_UNKNOWN;
+}
+
+static void
+cmd_set_hash_input_set_parsed(void *parsed_result,
+ __rte_unused struct cmdline *cl,
+ __rte_unused void *data)
+{
+   struct cmd_set_hash_input_set_result *res = parsed_result;
+   struct rte_eth_hash_filter_info info;
+
+   memset(&info, 0, sizeof(info));
+   info.info_type = RTE_ETH_HASH_FILTER_INPUT_SET_SELECT;
+   info.info.input_set_conf.flow_type = str2flowtype(res->flow_type);
+   info.info.input_set_conf.field[0] = str2inset(res->inset_field);
+   info.info.input_set_conf.inset_size = 1;
+   if (!strcmp(res->select, "select"))
+   info.info.input_set_conf.op = RTE_ETH_INPUT_SET_SELECT;
+   else if (!strcmp(res->select, "add"))
+   info.info.input_set_conf.op = RTE_ETH_INPUT_SET_ADD;
+   rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
+   RTE_ETH_FILTER_SET, &info);
+}
+
+cmdline_parse_token_string_t cmd_set_hash_input_set_cmd =
+   TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
+   set_hash_input_set, "set_hash_input_set");
+cmdline_parse_token_num_t cmd_set_hash_input_set_port_id =
+   TOKEN_NUM_INITIALIZER(struct cmd_set_hash_input_set_result,
+   port_id, UINT8);
+cmdline_parse_token_string_t cmd_set_hash_input_set_flow_type =
+   TOKEN_STRING_INITIALIZER(struct cmd_set_hash_input_set_result,
+   flow_type,
+   "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#"
+   "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload");
+cmdline_parse_token_string_t cmd_set_hash_input_set_field =
+   TOKEN_STRING_INITIALIZER(struct cmd_set_hash

[dpdk-dev] [PATCH v3 04/16] fm10k: add func to re-allocate mbuf for RX ring

2015-10-29 Thread Chen, Jing D
Hi, Steve,

Best Regards,
Mark


> -Original Message-
> From: Liang, Cunming
> Sent: Wednesday, October 28, 2015 9:59 PM
> To: Chen, Jing D; dev at dpdk.org
> Cc: Tao, Zhe; He, Shaopeng; Ananyev, Konstantin; Richardson, Bruce
> Subject: Re: [PATCH v3 04/16] fm10k: add func to re-allocate mbuf for RX ring
> 
> Hi Mark,
> 
> On 10/27/2015 5:46 PM, Chen Jing D(Mark) wrote:
> > From: "Chen Jing D(Mark)" 
> >
> > Add function fm10k_rxq_rearm to re-allocate mbuf for used desc
> > in RX HW ring.
> >
> > Signed-off-by: Chen Jing D(Mark) 
> > ---
> >   drivers/net/fm10k/fm10k.h  |9 
> >   drivers/net/fm10k/fm10k_ethdev.c   |3 +
> >   drivers/net/fm10k/fm10k_rxtx_vec.c |   90
> 
> >   3 files changed, 102 insertions(+), 0 deletions(-)
> [...]
> > +static inline void
> > +fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
> > +{
> > +   int i;
> > +   uint16_t rx_id;
> > +   volatile union fm10k_rx_desc *rxdp;
> > +   struct rte_mbuf **mb_alloc = &rxq->sw_ring[rxq->rxrearm_start];
> > +   struct rte_mbuf *mb0, *mb1;
> > +   __m128i head_off = _mm_set_epi64x(
> > +   RTE_PKTMBUF_HEADROOM +
> FM10K_RX_DATABUF_ALIGN - 1,
> > +   RTE_PKTMBUF_HEADROOM +
> FM10K_RX_DATABUF_ALIGN - 1);
> > +   __m128i dma_addr0, dma_addr1;
> > +   /* Rx buffer need to be aligned with 512 byte */
> > +   const __m128i hba_msk = _mm_set_epi64x(0,
> > +   UINT64_MAX - FM10K_RX_DATABUF_ALIGN
> + 1);
> > +
> > +   rxdp = rxq->hw_ring + rxq->rxrearm_start;
> > +
> > +   /* Pull 'n' more MBUFs into the software ring */
> > +   if (rte_mempool_get_bulk(rxq->mp,
> > +(void *)mb_alloc,
> > +RTE_FM10K_RXQ_REARM_THRESH) < 0) {
> Here's one potential issue when the failure happens. As tail won't
> update, the head will equal to tail in the end. HW won't write back
> anyway, however the SW recv_raw_pkts_vec only check DD bit, the old
> 'dirty' descriptor(DD bit is not clean) will be taken and continue move
> forward to check the next which even beyond the tail. I'm sorry didn't
> catch it on the first time. /Steve

I have a different view on this. In case mbuf allocation always failed and tail 
equaled to head, 
then HW will stop to send new packet to HW ring, as you pointed out. Then, when 
Mbuf can be allocated, this function will refill HW ring and update tail. So, 
HW will 
resume to fill packet to HW ring. Receive functions will continue to work. 
Anything I missed?

> > +   rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed
> +=
> > +   RTE_FM10K_RXQ_REARM_THRESH;
> > +   return;
> > +   }
> > +
> > +



[dpdk-dev] [PATCH v3 08/16] fm10k: add Vector RX scatter function

2015-10-29 Thread Chen, Jing D
Hi, Steve,

Best Regards,
Mark


> -Original Message-
> From: Liang, Cunming
> Sent: Wednesday, October 28, 2015 10:30 PM
> To: Chen, Jing D; dev at dpdk.org
> Cc: Tao, Zhe; He, Shaopeng; Ananyev, Konstantin; Richardson, Bruce
> Subject: Re: [PATCH v3 08/16] fm10k: add Vector RX scatter function
> 
> Hi Mark,
> 
> On 10/27/2015 5:46 PM, Chen Jing D(Mark) wrote:
> > From: "Chen Jing D(Mark)" 
> >
> > Add func fm10k_recv_scattered_pkts_vec to receive chained packets
> > with SSE instructions.
> >
> > Signed-off-by: Chen Jing D(Mark) 
> > ---
> >   drivers/net/fm10k/fm10k.h  |2 +
> >   drivers/net/fm10k/fm10k_rxtx_vec.c |   88
> 
> >   2 files changed, 90 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
> > index 1502ae3..06697fa 100644
> > --- a/drivers/net/fm10k/fm10k.h
> > +++ b/drivers/net/fm10k/fm10k.h
> > @@ -329,4 +329,6 @@ uint16_t fm10k_xmit_pkts(void *tx_queue, struct
> rte_mbuf **tx_pkts,
> >   int fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq);
> >   int fm10k_rx_vec_condition_check(struct rte_eth_dev *);
> >   uint16_t fm10k_recv_pkts_vec(void *, struct rte_mbuf **, uint16_t);
> > +uint16_t fm10k_recv_scattered_pkts_vec(void *, struct rte_mbuf **,
> > +   uint16_t);
> >   #endif
> > diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c
> b/drivers/net/fm10k/fm10k_rxtx_vec.c
> > index 2e6f1a2..3fd5d45 100644
> > --- a/drivers/net/fm10k/fm10k_rxtx_vec.c
> > +++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
> > @@ -513,3 +513,91 @@ fm10k_recv_pkts_vec(void *rx_queue, struct
> rte_mbuf **rx_pkts,
> >   {
> > return fm10k_recv_raw_pkts_vec(rx_queue, rx_pkts, nb_pkts,
> NULL);
> >   }
> > +
> > +static inline uint16_t
> > +fm10k_reassemble_packets(struct fm10k_rx_queue *rxq,
> > +   struct rte_mbuf **rx_bufs,
> > +   uint16_t nb_bufs, uint8_t *split_flags)
> > +{
> > +   struct rte_mbuf *pkts[RTE_FM10K_MAX_RX_BURST]; /*finished
> pkts*/
> > +   struct rte_mbuf *start = rxq->pkt_first_seg;
> > +   struct rte_mbuf *end =  rxq->pkt_last_seg;
> > +   unsigned pkt_idx, buf_idx;
> > +
> > +
> > +   for (buf_idx = 0, pkt_idx = 0; buf_idx < nb_bufs; buf_idx++) {
> > +   if (end != NULL) {
> > +   /* processing a split packet */
> > +   end->next = rx_bufs[buf_idx];
> > +   start->nb_segs++;
> > +   start->pkt_len += rx_bufs[buf_idx]->data_len;
> > +   end = end->next;
> > +
> > +   if (!split_flags[buf_idx]) {
> > +   /* it's the last packet of the set */
> > +   start->hash = end->hash;
> > +   start->ol_flags = end->ol_flags;
> > +   pkts[pkt_idx++] = start;
> > +   start = end = NULL;
> > +   }
> > +   } else {
> > +   /* not processing a split packet */
> > +   if (!split_flags[buf_idx]) {
> > +   /* not a split packet, save and skip */
> > +   pkts[pkt_idx++] = rx_bufs[buf_idx];
> > +   continue;
> > +   }
> > +   end = start = rx_bufs[buf_idx];
> > +   }
> I guess you forgot to consider the crc_len during processing. /Steve

In fm10k, crc is always be stripped and pkt_len/data_len carried actual
data length. So, we needn't add crc_len back here.  This is a little different
from IXGBE.



[dpdk-dev] [PATCH v2] i40e: Fix the statistics issue of i40e

2015-10-29 Thread Xutao Sun
The old statistics on i40e only counted the packets on ports.
So the discarding packets on VSI were not counted.
This patch is to make statistics for packets both on ports and VSI.

Signed-off-by: Xutao Sun 
---
 drivers/net/i40e/i40e_ethdev.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 40b0526..5e20fa7 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1511,21 +1511,26 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)
if (pf->main_vsi)
i40e_update_vsi_stats(pf->main_vsi);

-   stats->ipackets = ns->eth.rx_unicast + ns->eth.rx_multicast +
-   ns->eth.rx_broadcast;
-   stats->opackets = ns->eth.tx_unicast + ns->eth.tx_multicast +
-   ns->eth.tx_broadcast;
-   stats->ibytes   = ns->eth.rx_bytes;
-   stats->obytes   = ns->eth.tx_bytes;
-   stats->oerrors  = ns->eth.tx_errors;
-   stats->imcasts  = ns->eth.rx_multicast;
+   stats->ipackets = pf->main_vsi->eth_stats.rx_unicast +
+   pf->main_vsi->eth_stats.rx_multicast +
+   pf->main_vsi->eth_stats.rx_broadcast -
+   pf->main_vsi->eth_stats.rx_discards;
+   stats->opackets = pf->main_vsi->eth_stats.tx_unicast +
+   pf->main_vsi->eth_stats.tx_multicast +
+   pf->main_vsi->eth_stats.tx_broadcast;
+   stats->ibytes   = pf->main_vsi->eth_stats.rx_bytes;
+   stats->obytes   = pf->main_vsi->eth_stats.tx_bytes;
+   stats->oerrors  = ns->eth.tx_errors +
+   pf->main_vsi->eth_stats.tx_errors;
+   stats->imcasts  = pf->main_vsi->eth_stats.rx_multicast;
stats->fdirmatch = ns->fd_sb_match;

/* Rx Errors */
stats->ibadcrc  = ns->crc_errors;
stats->ibadlen  = ns->rx_length_errors + ns->rx_undersize +
ns->rx_oversize + ns->rx_fragments + ns->rx_jabber;
-   stats->imissed  = ns->eth.rx_discards;
+   stats->imissed  = ns->eth.rx_discards +
+   pf->main_vsi->eth_stats.rx_discards;
stats->ierrors  = stats->ibadcrc + stats->ibadlen + stats->imissed;

PMD_DRV_LOG(DEBUG, "* PF stats start 
***");
-- 
1.9.3



[dpdk-dev] [PATCH v6 0/3] i40e: RSS/FD granularity configuration

2015-10-29 Thread Helin Zhang
The default input set of fields of a received packet are loaded from
firmware, which cannot be modified even users want to use different
fields for RSS or flow director. Here adds more flexibilities of
selecting or adding packet fields for hash calculation or flow
director to users. It also includes the modifications in testpmd to
support the testing.

v2 changes:
Solved the compilation issues.

v3 changes:
Support selecting more input set fields.

v4 changes:
Removed operation of 'delete', as it is not necessary.
Added FD granularity in both pmd and testpmd, as it is similar to RSS
granularity.

v5 changes:
Fixed issue of generating wrong input set for registers on ipv6-udp and
ipv6-tcp pc types.
Added clear masking operations during checking if MASK registers are
opcupied or not.
Reworked several annotations.

v6 changes:
Updated documentation.

Helin Zhang (3):
  i40e: RSS/FD granularity configuration
  app/testpmd: add test commands for RSS/FD granularity
  doc: update release notes and testpmd guide

 app/test-pmd/cmdline.c  | 218 
 doc/guides/rel_notes/release_2_2.rst|   2 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  33 ++
 drivers/net/i40e/i40e_ethdev.c  | 742 
 drivers/net/i40e/i40e_ethdev.h  |   7 +
 drivers/net/i40e/i40e_fdir.c|  31 ++
 lib/librte_ether/rte_eth_ctrl.h | 114 -
 7 files changed, 1143 insertions(+), 4 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH v6 2/3] app/testpmd: add test commands for RSS/FD granularity

2015-10-29 Thread Helin Zhang
Test commands are added to support selecting input set, or adding
new input set per different pctype.

Signed-off-by: Helin Zhang 
Signed-off-by: Andrey Chilikin 
---
 app/test-pmd/cmdline.c | 218 +
 1 file changed, 218 insertions(+)

v3 changes:
Support selecting more input set fields.

v4 changes:
Removed operation of 'delete'.
Added test commands for FD granularity.

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index b3c36f3..1a2cb7d 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -690,6 +690,28 @@ static void cmd_help_long_parsed(void *parsed_result,

"ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)"
" (enable|disable)\n"
"Set the global configurations of hash filters.\n\n"
+
+   "set_hash_input_set (port_id) (ipv4|ipv4-frag|"
+   "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
+   "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
+   "l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|"
+   "dst-ipv6|ipv4-tos|ipv4-proto|ipv6-tc|"
+   "ipv6-next-header|udp-src-port|udp-dst-port|"
+   "tcp-src-port|tcp-dst-port|sctp-src-port|"
+   "sctp-dst-port|sctp-veri-tag|udp-key|gre-key|fld-1st|"
+   "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
+   "fld-8th|none) (select|add)\n"
+   "Set the input set for hash.\n\n"
+
+   "set_fdir_input_set (port_id) (ipv4|ipv4-frag|"
+   "ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|"
+   "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|"
+   "l2_payload) (src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|"
+   "udp-src-port|udp-dst-port|tcp-src-port|tcp-dst-port|"
+   "sctp-src-port|sctp-dst-port|sctp-veri-tag|fld-1st|"
+   "fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|"
+   "fld-8th|none) (select|add)\n"
+   "Set the input set for FDir.\n\n"
);
}
 }
@@ -9111,6 +9133,200 @@ cmdline_parse_inst_t cmd_set_hash_global_config = {
},
 };

+/* Set hash input set */
+struct cmd_set_hash_input_set_result {
+   cmdline_fixed_string_t set_hash_input_set;
+   uint8_t port_id;
+   cmdline_fixed_string_t flow_type;
+   cmdline_fixed_string_t inset_field;
+   cmdline_fixed_string_t select;
+};
+
+static enum rte_eth_input_set_field
+str2inset(char *string)
+{
+   uint16_t i;
+
+   static const struct {
+   char str[32];
+   enum rte_eth_input_set_field inset;
+   } inset_table[] = {
+   {"ovlan", RTE_ETH_INPUT_SET_L2_OUTER_VLAN},
+   {"ivlan", RTE_ETH_INPUT_SET_L2_INNER_VLAN},
+   {"src-ipv4", RTE_ETH_INPUT_SET_L3_SRC_IP4},
+   {"dst-ipv4", RTE_ETH_INPUT_SET_L3_DST_IP4},
+   {"ipv4-tos", RTE_ETH_INPUT_SET_L3_IP4_TOS},
+   {"ipv4-proto", RTE_ETH_INPUT_SET_L3_IP4_PROTO},
+   {"src-ipv6", RTE_ETH_INPUT_SET_L3_SRC_IP6},
+   {"dst-ipv6", RTE_ETH_INPUT_SET_L3_DST_IP6},
+   {"ipv6-tc", RTE_ETH_INPUT_SET_L3_IP6_TC},
+   {"ipv6-next-header", RTE_ETH_INPUT_SET_L3_IP6_NEXT_HEADER},
+   {"udp-src-port", RTE_ETH_INPUT_SET_L4_UDP_SRC_PORT},
+   {"udp-dst-port", RTE_ETH_INPUT_SET_L4_UDP_DST_PORT},
+   {"tcp-src-port", RTE_ETH_INPUT_SET_L4_TCP_SRC_PORT},
+   {"tcp-dst-port", RTE_ETH_INPUT_SET_L4_TCP_DST_PORT},
+   {"sctp-src-port", RTE_ETH_INPUT_SET_L4_SCTP_SRC_PORT},
+   {"sctp-dst-port", RTE_ETH_INPUT_SET_L4_SCTP_DST_PORT},
+   {"sctp-veri-tag", RTE_ETH_INPUT_SET_L4_SCTP_VERIFICATION_TAG},
+   {"udp-key", RTE_ETH_INPUT_SET_TUNNEL_L4_UDP_KEY},
+   {"gre-key", RTE_ETH_INPUT_SET_TUNNEL_GRE_KEY},
+   {"fld-1st", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_1ST_WORD},
+   {"fld-2nd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_2ND_WORD},
+   {"fld-3rd", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_3RD_WORD},
+   {"fld-4th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_4TH_WORD},
+   {"fld-5th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_5TH_WORD},
+   {"fld-6th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_6TH_WORD},
+   {"fld-7th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_7TH_WORD},
+   {"fld-8th", RTE_ETH_INPUT_SET_FLEX_PAYLOAD_8TH_WORD},
+   {"none", RTE_ETH_INPUT_SET_NONE},
+   };
+
+   for (i = 0; i < RTE_DIM(inset_table); i++) {
+   if (!strcmp(string, inset_table[i].str))
+   return inset_table[i].inset;
+   }
+
+   return RTE_ETH_INPUT_SET_UNKNOWN;
+}
+
+static v

[dpdk-dev] [PATCH v6 1/3] i40e: RSS/FD granularity configuration

2015-10-29 Thread Helin Zhang
The default input set of fields of a received packet are loaded from
firmware, which cannot be modified even users want to use different
fields for RSS or flow director. Here adds more flexibilities of
selecting packet fields for hash calculation or flow director for
users.

Signed-off-by: Helin Zhang 
Signed-off-by: Andrey Chilikin 
---
 drivers/net/i40e/i40e_ethdev.c  | 742 
 drivers/net/i40e/i40e_ethdev.h  |   7 +
 drivers/net/i40e/i40e_fdir.c|  31 ++
 lib/librte_ether/rte_eth_ctrl.h | 114 +-
 4 files changed, 890 insertions(+), 4 deletions(-)

v2 changes:
Solved the compilation issues.

v3 changes:
Support selecting more input set fields.

v4 changes:
Removed operation of 'delete', as it is not necessary.
Added FD granularity, as it is similar to RSS granularity.

v5 changes:
Fixed issue of generating wrong input set for registers on ipv6-udp and 
ipv6-tcp pc types.
Added clear masking operations during checking if MASK registers are opcupied 
or not.
Reworked several annotations.

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 478e94d..fb262a5 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -113,6 +113,142 @@
 #define I40E_PRTTSYN_TSYNENA  0x8000
 #define I40E_PRTTSYN_TSYNTYPE 0x0e00

+#define I40E_PRTQF_FD_INSET(_i, _j)  (0x0025 + ((_i) * 64 + (_j) * 32))
+#define I40E_GLQF_FD_MSK(_i, _j) (0x00267200 + ((_i) * 4 + (_j) * 8))
+#define I40E_GLQF_FD_MSK_FIELD   0x
+#define I40E_GLQF_HASH_INSET(_i, _j) (0x00267600 + ((_i) * 4 + (_j) * 8))
+#define I40E_GLQF_HASH_MSK(_i, _j)   (0x00267A00 + ((_i) * 4 + (_j) * 8))
+#define I40E_GLQF_HASH_MSK_FIELD  0x
+
+#define I40E_INSET_NONE0x0ULL
+
+/* bit0 ~ bit 7 */
+#define I40E_INSET_DMAC0x0001ULL
+#define I40E_INSET_SMAC0x0002ULL
+#define I40E_INSET_VLAN_OUTER  0x0004ULL
+#define I40E_INSET_VLAN_INNER  0x0008ULL
+#define I40E_INSET_VLAN_TUNNEL 0x0010ULL
+
+/* bit 8 ~ bit 15 */
+#define I40E_INSET_IPV4_SRC0x0100ULL
+#define I40E_INSET_IPV4_DST0x0200ULL
+#define I40E_INSET_IPV6_SRC0x0400ULL
+#define I40E_INSET_IPV6_DST0x0800ULL
+#define I40E_INSET_SRC_PORT0x1000ULL
+#define I40E_INSET_DST_PORT0x2000ULL
+#define I40E_INSET_SCTP_VT 0x4000ULL
+
+/* bit 16 ~ bit 31 */
+#define I40E_INSET_IPV4_TOS0x0001ULL
+#define I40E_INSET_IPV4_PROTO  0x0002ULL
+#define I40E_INSET_IPV4_TTL0x0004ULL
+#define I40E_INSET_IPV6_TC 0x0008ULL
+#define I40E_INSET_IPV6_FLOW   0x0010ULL
+#define I40E_INSET_IPV6_NEXT_HDR   0x0020ULL
+#define I40E_INSET_IPV6_HOP_LIMIT  0x0040ULL
+#define I40E_INSET_TCP_FLAGS   0x0080ULL
+
+/* bit 32 ~ bit 47, tunnel fields */
+#define I40E_INSET_TUNNEL_IPV4_DST   0x0001ULL
+#define I40E_INSET_TUNNEL_IPV6_DST   0x0002ULL
+#define I40E_INSET_TUNNEL_DMAC   0x0004ULL
+#define I40E_INSET_TUNNEL_SRC_PORT   0x0008ULL
+#define I40E_INSET_TUNNEL_DST_PORT   0x0010ULL
+#define I40E_INSET_TUNNEL_ID 0x0020ULL
+
+/* bit 48 ~ bit 55 */
+#define I40E_INSET_LAST_ETHER_TYPE 0x0001ULL
+
+/* bit 56 ~ bit 63, Flex Payload */
+#define I40E_INSET_FLEX_PAYLOAD_W1 0x0100ULL
+#define I40E_INSET_FLEX_PAYLOAD_W2 0x0200ULL
+#define I40E_INSET_FLEX_PAYLOAD_W3 0x0400ULL
+#define I40E_INSET_FLEX_PAYLOAD_W4 0x0800ULL
+#define I40E_INSET_FLEX_PAYLOAD_W5 0x1000ULL
+#define I40E_INSET_FLEX_PAYLOAD_W6 0x2000ULL
+#define I40E_INSET_FLEX_PAYLOAD_W7 0x4000ULL
+#define I40E_INSET_FLEX_PAYLOAD_W8 0x8000ULL
+#define I40E_INSET_FLEX_PAYLOAD \
+   (I40E_INSET_FLEX_PAYLOAD_W1 | I40E_INSET_FLEX_PAYLOAD_W2 | \
+   I40E_INSET_FLEX_PAYLOAD_W3 | I40E_INSET_FLEX_PAYLOAD_W3 | \
+   I40E_INSET_FLEX_PAYLOAD_W5 | I40E_INSET_FLEX_PAYLOAD_W6 | \
+   I40E_INSET_FLEX_PAYLOAD_W7 | I40E_INSET_FLEX_PAYLOAD_W8)
+
+/**
+ * Below are values for writing un-exposed registers suggested
+ * by silicon experts
+ */
+/* Destination MAC address */
+#define I40E_REG_INSET_L2_DMAC   0xE000ULL
+/* Source MAC address */
+#define I40E_REG_INSET_L2_SMAC   0x1C00ULL
+/* VLAN tag in the outer L2 header */
+#define I40E_REG_INSET_L2_OUTER_VLAN 0x0080ULL
+/* VLAN tag in the inner L2 header */
+#define I40E_REG_INSET_L2_INNER_VLAN 0x0100ULL
+/* Source IPv4 address */
+#define I40E_REG_INSET_L3_SRC_IP40x00018000ULL
+/* Destination IPv4 address */
+

[dpdk-dev] [PATCH v6 3/3] doc: update release notes and testpmd guide

2015-10-29 Thread Helin Zhang
Update release notes with the newly added feature of RSS/FD input
set granularity, and testpmd guide with newly added commands for
RSS/FD input set granularity testing.

Signed-off-by: Helin Zhang 
---
 doc/guides/rel_notes/release_2_2.rst|  2 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 33 +
 2 files changed, 35 insertions(+)

diff --git a/doc/guides/rel_notes/release_2_2.rst 
b/doc/guides/rel_notes/release_2_2.rst
index be6f827..8fc8917 100644
--- a/doc/guides/rel_notes/release_2_2.rst
+++ b/doc/guides/rel_notes/release_2_2.rst
@@ -23,6 +23,8 @@ New Features

 * **Added vhost-user multiple queue support.**

+* **Added RSS/FD input set granularity on Intel X710/XL710.**
+

 Resolved Issues
 ---
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst 
b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 71d831b..f5951c0 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1777,3 +1777,36 @@ Set the global configurations of hash filters::
 For example, to enable simple_xor for flow type of ipv6 on port 2::

testpmd> set_hash_global_config 2 simple_xor ipv6 enable
+
+set_hash_input_set
+~~
+
+Set the input set for hash::
+
+   set_hash_input_set (port_id) (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp| \
+   ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other| \
+   l2_payload) (ovlan|ivlan|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|ipv4-tos| \
+   ipv4-proto|ipv6-tc|ipv6-next-header|udp-src-port|udp-dst-port| \
+   tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag| \
+   udp-key|gre-key|fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th| \
+   fld-8th|none) (select|add)
+
+For example, to add source IP to hash input set for flow type of ipv4 on port 
0::
+
+   testpmd> set_hash_input_set 0 ipv4 src-ipv4 add
+
+set_fdir_input_set
+~~
+
+Set the input set for Fdir::
+
+   set_fdir_input_set (port_id) (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp| \
+   ipv4-other|ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)
+   (src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|udp-src-port|udp-dst-port| \
+   tcp-src-port|tcp-dst-port|sctp-src-port|sctp-dst-port|sctp-veri-tag| \
+   fld-1st|fld-2nd|fld-3rd|fld-4th|fld-5th|fld-6th|fld-7th|fld-8th|none) \
+   (select|add)
+
+For example to add source IP to FD input set for flow type of ipv4 on port 0::
+
+   testpmd> set_fdir_input_set 0 ipv4 src-ipv4 add
-- 
1.9.3



[dpdk-dev] [PATCH v3 1/3] i40e: add selecting GRE key length

2015-10-29 Thread Helin Zhang
By default, only first 3 bytes of GRE key will be used for hash or
FD calculation. With these changes, it can select 3 or 4 bytes of
GRE key for hash or FD calculation.

Signed-off-by: Helin Zhang 
Signed-off-by: Andrey Chilikin 
---
 drivers/net/i40e/i40e_ethdev.c  | 87 +++--
 lib/librte_ether/rte_eth_ctrl.h | 20 ++
 2 files changed, 104 insertions(+), 3 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index fb262a5..8de8aee 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -5339,7 +5339,7 @@ i40e_pf_config_rss(struct i40e_pf *pf)

 static int
 i40e_tunnel_filter_param_check(struct i40e_pf *pf,
-   struct rte_eth_tunnel_filter_conf *filter)
+  struct rte_eth_tunnel_filter_conf *filter)
 {
if (pf == NULL || filter == NULL) {
PMD_DRV_LOG(ERR, "Invalid parameter");
@@ -5371,9 +5371,85 @@ i40e_tunnel_filter_param_check(struct i40e_pf *pf,
return 0;
 }

+#define I40E_GL_PRS_FVBM_MSK_ENA 0x8000
+#define I40E_GL_PRS_FVBM(_i) (0x00269760 + ((_i) * 4))
 static int
-i40e_tunnel_filter_handle(struct rte_eth_dev *dev, enum rte_filter_op 
filter_op,
-   void *arg)
+i40e_dev_set_gre_key_len(struct i40e_hw *hw, uint8_t len)
+{
+   uint32_t val, reg;
+   int ret = -EINVAL;
+
+   val = I40E_READ_REG(hw, I40E_GL_PRS_FVBM(2));
+   PMD_DRV_LOG(DEBUG, "Read original GL_PRS_FVBM with 0x%08x\n", val);
+
+   if (len == 3) {
+   reg = val | I40E_GL_PRS_FVBM_MSK_ENA;
+   } else if (len == 4) {
+   reg = val & ~I40E_GL_PRS_FVBM_MSK_ENA;
+   } else {
+   PMD_DRV_LOG(ERR, "Unsupported GRE key length of %u", len);
+   return ret;
+   }
+
+   if (reg != val) {
+   ret = i40e_aq_debug_write_register(hw, I40E_GL_PRS_FVBM(2),
+  reg, NULL);
+   if (ret != 0)
+   return ret;
+   } else {
+   ret = 0;
+   }
+   PMD_DRV_LOG(DEBUG, "Read modified GL_PRS_FVBM with 0x%08x\n",
+   I40E_READ_REG(hw, I40E_GL_PRS_FVBM(2)));
+
+   return ret;
+}
+
+static int
+i40e_dev_global_config_set(struct i40e_hw *hw, struct rte_eth_global_cfg *cfg)
+{
+   int ret = -EINVAL;
+
+   if (!hw || !cfg)
+   return -EINVAL;
+
+   switch (cfg->cfg_type) {
+   case RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN:
+   ret = i40e_dev_set_gre_key_len(hw, cfg->cfg.gre_key_len);
+   break;
+   default:
+   PMD_DRV_LOG(ERR, "Unknown config type %u", cfg->cfg_type);
+   break;
+   }
+
+   return ret;
+}
+
+static int
+i40e_filter_ctrl_global_config(struct rte_eth_dev *dev,
+  enum rte_filter_op filter_op,
+  void *arg)
+{
+   struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   int ret = I40E_ERR_PARAM;
+
+   switch (filter_op) {
+   case RTE_ETH_FILTER_SET:
+   ret = i40e_dev_global_config_set(hw,
+   (struct rte_eth_global_cfg *)arg);
+   break;
+   default:
+   PMD_DRV_LOG(ERR, "unknown operation %u", filter_op);
+   break;
+   }
+
+   return ret;
+}
+
+static int
+i40e_tunnel_filter_handle(struct rte_eth_dev *dev,
+ enum rte_filter_op filter_op,
+ void *arg)
 {
struct rte_eth_tunnel_filter_conf *filter;
struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
@@ -5388,6 +5464,7 @@ i40e_tunnel_filter_handle(struct rte_eth_dev *dev, enum 
rte_filter_op filter_op,
case RTE_ETH_FILTER_NOP:
if (!(pf->flags & I40E_FLAG_VXLAN))
ret = I40E_NOT_SUPPORTED;
+   break;
case RTE_ETH_FILTER_ADD:
ret = i40e_dev_tunnel_filter_set(pf, filter, 1);
break;
@@ -6386,6 +6463,10 @@ i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
return -EINVAL;

switch (filter_type) {
+   case RTE_ETH_FILTER_NONE:
+   /* For global configuration */
+   ret = i40e_filter_ctrl_global_config(dev, filter_op, arg);
+   break;
case RTE_ETH_FILTER_HASH:
ret = i40e_hash_filter_ctrl(dev, filter_op, arg);
break;
diff --git a/lib/librte_ether/rte_eth_ctrl.h b/lib/librte_ether/rte_eth_ctrl.h
index 11829f1..651a00c 100644
--- a/lib/librte_ether/rte_eth_ctrl.h
+++ b/lib/librte_ether/rte_eth_ctrl.h
@@ -295,6 +295,26 @@ struct rte_eth_tunnel_filter_conf {
uint16_t queue_id;  /** < queue number. */
 };

+/**
+ * Global eth device configuration type.
+ */
+enum rte_eth_global_cfg_type {
+   RTE_ETH_GLOBAL_CFG_TYPE_UNKNOWN = 0,
+   RTE_ETH_GLOBAL_CFG_TYPE_

[dpdk-dev] [PATCH v3 2/3] app/testpmd: add test commands for selecting different GRE key sizes

2015-10-29 Thread Helin Zhang
Test commands are added to support selecting differnt length of GRE key.

Signed-off-by: Helin Zhang 
Signed-off-by: Andrey Chilikin 
---
 app/test-pmd/cmdline.c | 52 ++
 1 file changed, 52 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 1a2cb7d..cd49637 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -6645,6 +6645,57 @@ cmdline_parse_inst_t cmd_tunnel_udp_config = {
},
 };

+/* *** GLOBAL CONFIG *** */
+struct cmd_global_config_result {
+   cmdline_fixed_string_t cmd;
+   uint8_t port_id;
+   cmdline_fixed_string_t cfg_type;
+   uint8_t len;
+};
+
+static void
+cmd_global_config_parsed(void *parsed_result,
+__attribute__((unused)) struct cmdline *cl,
+__attribute__((unused)) void *data)
+{
+   struct cmd_global_config_result *res = parsed_result;
+   struct rte_eth_global_cfg conf;
+   int ret;
+
+   memset(&conf, 0, sizeof(conf));
+   conf.cfg_type = RTE_ETH_GLOBAL_CFG_TYPE_GRE_KEY_LEN;
+   conf.cfg.gre_key_len = res->len;
+   ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_NONE,
+ RTE_ETH_FILTER_SET, &conf);
+   if (ret != 0)
+   printf("Global config error\n");
+}
+
+cmdline_parse_token_string_t cmd_global_config_cmd =
+   TOKEN_STRING_INITIALIZER(struct cmd_global_config_result, cmd,
+   "global_config");
+cmdline_parse_token_num_t cmd_global_config_port_id =
+   TOKEN_NUM_INITIALIZER(struct cmd_global_config_result, port_id, UINT8);
+cmdline_parse_token_string_t cmd_global_config_type =
+   TOKEN_STRING_INITIALIZER(struct cmd_global_config_result,
+   cfg_type, "gre-key-len");
+cmdline_parse_token_num_t cmd_global_config_gre_key_len =
+   TOKEN_NUM_INITIALIZER(struct cmd_global_config_result,
+   len, UINT8);
+
+cmdline_parse_inst_t cmd_global_config = {
+   .f = cmd_global_config_parsed,
+   .data = (void *)NULL,
+   .help_str = "global_config  gre-key-len ",
+   .tokens = {
+   (void *)&cmd_global_config_cmd,
+   (void *)&cmd_global_config_port_id,
+   (void *)&cmd_global_config_type,
+   (void *)&cmd_global_config_gre_key_len,
+   NULL,
+   },
+};
+
 /* *** CONFIGURE VM MIRROR VLAN/POOL RULE *** */
 struct cmd_set_mirror_mask_result {
cmdline_fixed_string_t set;
@@ -9484,6 +9535,7 @@ cmdline_parse_ctx_t main_ctx[] = {
(cmdline_parse_inst_t *)&cmd_vf_rate_limit,
(cmdline_parse_inst_t *)&cmd_tunnel_filter,
(cmdline_parse_inst_t *)&cmd_tunnel_udp_config,
+   (cmdline_parse_inst_t *)&cmd_global_config,
(cmdline_parse_inst_t *)&cmd_set_mirror_mask,
(cmdline_parse_inst_t *)&cmd_set_mirror_link,
(cmdline_parse_inst_t *)&cmd_reset_mirror_rule,
-- 
1.9.3



[dpdk-dev] [PATCH v3 0/3] add selecting different GRE key length

2015-10-29 Thread Helin Zhang
By default, only 3 bytes of GRE key will be used for hash or FD
calculation. Here adds selecting 3 or 4 bytes of GRE key for those
purpose.
Note that these patches are based on another patch set of
"[PATCH v6 0/2] i40e: RSS/FD granularity configuration".

v2 changes:
Updated with RSS/FD granularity code.

v3 changes:
Updated with RSS/FD granularity code.
Updated documentation.

Helin Zhang (3):
  i40e: add selecting GRE key length
  app/testpmd: add test commands for selecting different GRE key sizes
  doc: update release notes and testpmd guide

 app/test-pmd/cmdline.c  | 52 +
 doc/guides/rel_notes/release_2_2.rst|  2 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 
 drivers/net/i40e/i40e_ethdev.c  | 87 -
 lib/librte_ether/rte_eth_ctrl.h | 20 +++
 5 files changed, 169 insertions(+), 3 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH v3 3/3] doc: update release notes and testpmd guide

2015-10-29 Thread Helin Zhang
Update release notes with the newly added feature of selecting
different GRE key length for input set, and testpmd guide with
newly added commands for that.

Signed-off-by: Helin Zhang 
---
 doc/guides/rel_notes/release_2_2.rst|  2 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 +++
 2 files changed, 13 insertions(+)

diff --git a/doc/guides/rel_notes/release_2_2.rst 
b/doc/guides/rel_notes/release_2_2.rst
index 8fc8917..7b4b97e 100644
--- a/doc/guides/rel_notes/release_2_2.rst
+++ b/doc/guides/rel_notes/release_2_2.rst
@@ -25,6 +25,8 @@ New Features

 * **Added RSS/FD input set granularity on Intel X710/XL710.**

+* **Added selecting different GRE key length for input set on Intel 
X710/XL710.**
+

 Resolved Issues
 ---
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst 
b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index f5951c0..5ed7c66 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1810,3 +1810,14 @@ Set the input set for Fdir::
 For example to add source IP to FD input set for flow type of ipv4 on port 0::

testpmd> set_fdir_input_set 0 ipv4 src-ipv4 add
+
+global_config
+~
+
+Set different GRE key length for input set::
+
+   global_config (port_id) gre-key-len (number in bytes)
+
+For example to set GRE key length for input set to 4 bytes on port 0::
+
+   testpmd> global_config 0 gre-key-len 4
-- 
1.9.3



[dpdk-dev] [PATCH v6 2/9] null: fix segfault when null_pmd added to bonding

2015-10-29 Thread Tetsuya Mukawa
On 2015/10/28 22:43, Kulasek, TomaszX wrote:
>> -Original Message-
>> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
>> Sent: Tuesday, October 27, 2015 17:59
>> To: Kulasek, TomaszX
>> Cc: dev at dpdk.org; Tetsuya Mukawa
>> Subject: Re: [dpdk-dev] [PATCH v6 2/9] null: fix segfault when null_pmd
>> added to bonding
>>
>> Hi,
>> There is no change in v6 for this patch which was acked by Tetsuya.
>> So why not keep the Acked-by below your Signed-off-by?
>>
>> It seems patches 2, 3, 4 and 5 were Acked by Tetsuya.
>> Other acks I'm missing?
>>
> Hi,
>
> Patches 4 and 5 were changed due to the Tetsuya's suggestions and already 
> reviewed. There are not big changes, but I'm not sure if it should be reacked 
> by Tetsuya, or I can just copy ack?
>
> Tomasz

Hi Tomasz,

Could you please check Bernard's patch series?
 - [PATCH v5 00/28] remove pci driver from vdevs
He tries to remove pci_drv from PMD.

It seems your below patch will be affected by his patch.
 - null: fix segfault when null_pmd added to bonding

I just wonder your bonding RSS patch works without below fixing.
drivers/net/null/rte_eth_null.c :
+   pci_dev->driver = &rte_null_pmd.pci_drv;

Anyway, Could you please check him patches?

Thanks,
Tetsuya


[dpdk-dev] [PATCH v3 3/3] doc: update release notes and testpmd guide

2015-10-29 Thread Thomas Monjalon
Hi Helin,

Please avoid making a commit for doc only.
These changes are related to some code changes and must be atomic.
For next time, please update the release notes in the patch adding the
feature (i40e here) and the testpmd doc in the testpmd patch.

Thanks for explaining the logic to others

2015-10-29 14:18, Helin Zhang:
> Update release notes with the newly added feature of selecting
> different GRE key length for input set, and testpmd guide with
> newly added commands for that.
> 
> Signed-off-by: Helin Zhang 



[dpdk-dev] [PATCH v3] examples/vmdq: Fix the core dump issue when mem_pool is more than 34

2015-10-29 Thread De Lara Guarch, Pablo


> -Original Message-
> From: Sun, Xutao
> Sent: Tuesday, October 27, 2015 8:59 AM
> To: dev at dpdk.org
> Cc: De Lara Guarch, Pablo; Wu, Jingjing; Zhang, Helin; Sun, Xutao
> Subject: [PATCH v3] examples/vmdq: Fix the core dump issue when
> mem_pool is more than 34
> 
> Macro MAX_QUEUES was defined to 128, only allow 16 vmdq_pools in
> theory.
> When running vmdq_app with more than 34 vmdq_pools, it will cause the
> core_dump issue.
> Change MAX_QUEUES to 1024 will solve this issue.
> 
> Signed-off-by: Xutao Sun 
> ---
> v2:
>  - Rectify the NUM_MBUFS_PER_PORT since MAX_QUEUES has been
> changed
> 
> v3:
>  - Change the comments above the relevant code.
> 
>  examples/vmdq/main.c | 9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c
> index a142d49..178af2f 100644
> --- a/examples/vmdq/main.c
> +++ b/examples/vmdq/main.c
> @@ -69,12 +69,13 @@
>  #include 
>  #include 
> 
> -#define MAX_QUEUES 128
> +#define MAX_QUEUES 1024
>  /*
> - * For 10 GbE, 128 queues require roughly
> - * 128*512 (RX/TX_queue_nb * RX/TX_ring_descriptors_nb) per port.
> + * 1024 queues require to meet the needs of a large number of
> vmdq_pools.
> + * (RX/TX_queue_nb * RX/TX_ring_descriptors_nb) per port.
>   */
> -#define NUM_MBUFS_PER_PORT (128*512)
> +#define NUM_MBUFS_PER_PORT (MAX_QUEUES *
> RTE_MAX(RTE_TEST_RX_DESC_DEFAULT, \
> +
>   RTE_TEST_TX_DESC_DEFAULT))
>  #define MBUF_CACHE_SIZE 64
> 
>  #define MAX_PKT_BURST 32
> --
> 1.9.3

Acked-by: Pablo de Lara 



[dpdk-dev] [PATCH v3 0/2] i40e: Fix the statistics issue of i40e

2015-10-29 Thread Xutao Sun
The old statistics on i40e only counted the packets on ports.
So the discarding packets on VSI were not counted.
This patch is to make statistics for packets both on ports and VSI.

v2 changes:
Reword comments.

v3 changes:
Update documentation.

Xutao Sun (2):
  i40e: Fix the statistics issue of i40e
  doc: update release notes

 doc/guides/rel_notes/release_2_1.rst |  5 +
 drivers/net/i40e/i40e_ethdev.c   | 23 ++-
 2 files changed, 19 insertions(+), 9 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH v3 1/2] i40e: Fix the statistics issue of i40e

2015-10-29 Thread Xutao Sun
The old statistics on i40e only counted the packets on ports.
So the discarding packets on VSI were not counted.
This patch is to make statistics for packets both on ports and VSI.

Signed-off-by: Xutao Sun 
---
v2:
 - reword comments

 drivers/net/i40e/i40e_ethdev.c | 23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 40b0526..5e20fa7 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -1511,21 +1511,26 @@ i40e_dev_stats_get(struct rte_eth_dev *dev, struct 
rte_eth_stats *stats)
if (pf->main_vsi)
i40e_update_vsi_stats(pf->main_vsi);

-   stats->ipackets = ns->eth.rx_unicast + ns->eth.rx_multicast +
-   ns->eth.rx_broadcast;
-   stats->opackets = ns->eth.tx_unicast + ns->eth.tx_multicast +
-   ns->eth.tx_broadcast;
-   stats->ibytes   = ns->eth.rx_bytes;
-   stats->obytes   = ns->eth.tx_bytes;
-   stats->oerrors  = ns->eth.tx_errors;
-   stats->imcasts  = ns->eth.rx_multicast;
+   stats->ipackets = pf->main_vsi->eth_stats.rx_unicast +
+   pf->main_vsi->eth_stats.rx_multicast +
+   pf->main_vsi->eth_stats.rx_broadcast -
+   pf->main_vsi->eth_stats.rx_discards;
+   stats->opackets = pf->main_vsi->eth_stats.tx_unicast +
+   pf->main_vsi->eth_stats.tx_multicast +
+   pf->main_vsi->eth_stats.tx_broadcast;
+   stats->ibytes   = pf->main_vsi->eth_stats.rx_bytes;
+   stats->obytes   = pf->main_vsi->eth_stats.tx_bytes;
+   stats->oerrors  = ns->eth.tx_errors +
+   pf->main_vsi->eth_stats.tx_errors;
+   stats->imcasts  = pf->main_vsi->eth_stats.rx_multicast;
stats->fdirmatch = ns->fd_sb_match;

/* Rx Errors */
stats->ibadcrc  = ns->crc_errors;
stats->ibadlen  = ns->rx_length_errors + ns->rx_undersize +
ns->rx_oversize + ns->rx_fragments + ns->rx_jabber;
-   stats->imissed  = ns->eth.rx_discards;
+   stats->imissed  = ns->eth.rx_discards +
+   pf->main_vsi->eth_stats.rx_discards;
stats->ierrors  = stats->ibadcrc + stats->ibadlen + stats->imissed;

PMD_DRV_LOG(DEBUG, "* PF stats start 
***");
-- 
1.9.3



[dpdk-dev] [PATCH v3 2/2] doc: update release notes

2015-10-29 Thread Xutao Sun
Update release notes with the newly resolved issues about statistics on i40e.

Signed-off-by: Xutao Sun 
---
 doc/guides/rel_notes/release_2_1.rst | 5 +
 1 file changed, 5 insertions(+)

diff --git a/doc/guides/rel_notes/release_2_1.rst 
b/doc/guides/rel_notes/release_2_1.rst
index 103a5ee..897f939 100644
--- a/doc/guides/rel_notes/release_2_1.rst
+++ b/doc/guides/rel_notes/release_2_1.rst
@@ -676,6 +676,11 @@ Resolved Issues
 * **i40e: Fix registers access from big endian CPU.**


+* **i40e: Fix statistics of packets.**
+
+  Add discarding packets on VSI to the stats and rectify the old statistics.
+
+
 * **i40evf: Clear command when error occurs.**


-- 
1.9.3



[dpdk-dev] [PATCH v3 08/16] fm10k: add Vector RX scatter function

2015-10-29 Thread Liang, Cunming
Hi Mark,

> -Original Message-
> From: Chen, Jing D
> Sent: Thursday, October 29, 2015 1:28 PM
> To: Liang, Cunming; dev at dpdk.org
> Cc: Tao, Zhe; He, Shaopeng; Ananyev, Konstantin; Richardson, Bruce
> Subject: RE: [PATCH v3 08/16] fm10k: add Vector RX scatter function
> 
> Hi, Steve,
> 
> Best Regards,
> Mark
> 
> 
> > -Original Message-
> > From: Liang, Cunming
> > Sent: Wednesday, October 28, 2015 10:30 PM
> > To: Chen, Jing D; dev at dpdk.org
> > Cc: Tao, Zhe; He, Shaopeng; Ananyev, Konstantin; Richardson, Bruce
> > Subject: Re: [PATCH v3 08/16] fm10k: add Vector RX scatter function
> >
> > Hi Mark,
> >
> > On 10/27/2015 5:46 PM, Chen Jing D(Mark) wrote:
> > > From: "Chen Jing D(Mark)" 
> > >
> > > Add func fm10k_recv_scattered_pkts_vec to receive chained packets
> > > with SSE instructions.
> > >
> > > Signed-off-by: Chen Jing D(Mark) 
> > > ---
> > >   drivers/net/fm10k/fm10k.h  |2 +
> > >   drivers/net/fm10k/fm10k_rxtx_vec.c |   88
> > 
> > >   2 files changed, 90 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
> > > index 1502ae3..06697fa 100644
> > > --- a/drivers/net/fm10k/fm10k.h
> > > +++ b/drivers/net/fm10k/fm10k.h
> > > @@ -329,4 +329,6 @@ uint16_t fm10k_xmit_pkts(void *tx_queue, struct
> > rte_mbuf **tx_pkts,
> > >   int fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq);
> > >   int fm10k_rx_vec_condition_check(struct rte_eth_dev *);
> > >   uint16_t fm10k_recv_pkts_vec(void *, struct rte_mbuf **, uint16_t);
> > > +uint16_t fm10k_recv_scattered_pkts_vec(void *, struct rte_mbuf **,
> > > + uint16_t);
> > >   #endif
> > > diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c
> > b/drivers/net/fm10k/fm10k_rxtx_vec.c
> > > index 2e6f1a2..3fd5d45 100644
> > > --- a/drivers/net/fm10k/fm10k_rxtx_vec.c
> > > +++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
> > > @@ -513,3 +513,91 @@ fm10k_recv_pkts_vec(void *rx_queue, struct
> > rte_mbuf **rx_pkts,
> > >   {
> > >   return fm10k_recv_raw_pkts_vec(rx_queue, rx_pkts, nb_pkts,
> > NULL);
> > >   }
> > > +
> > > +static inline uint16_t
> > > +fm10k_reassemble_packets(struct fm10k_rx_queue *rxq,
> > > + struct rte_mbuf **rx_bufs,
> > > + uint16_t nb_bufs, uint8_t *split_flags)
> > > +{
> > > + struct rte_mbuf *pkts[RTE_FM10K_MAX_RX_BURST]; /*finished
> > pkts*/
> > > + struct rte_mbuf *start = rxq->pkt_first_seg;
> > > + struct rte_mbuf *end =  rxq->pkt_last_seg;
> > > + unsigned pkt_idx, buf_idx;
> > > +
> > > +
> > > + for (buf_idx = 0, pkt_idx = 0; buf_idx < nb_bufs; buf_idx++) {
> > > + if (end != NULL) {
> > > + /* processing a split packet */
> > > + end->next = rx_bufs[buf_idx];
> > > + start->nb_segs++;
> > > + start->pkt_len += rx_bufs[buf_idx]->data_len;
> > > + end = end->next;
> > > +
> > > + if (!split_flags[buf_idx]) {
> > > + /* it's the last packet of the set */
> > > + start->hash = end->hash;
> > > + start->ol_flags = end->ol_flags;
> > > + pkts[pkt_idx++] = start;
> > > + start = end = NULL;
> > > + }
> > > + } else {
> > > + /* not processing a split packet */
> > > + if (!split_flags[buf_idx]) {
> > > + /* not a split packet, save and skip */
> > > + pkts[pkt_idx++] = rx_bufs[buf_idx];
> > > + continue;
> > > + }
> > > + end = start = rx_bufs[buf_idx];
> > > + }
> > I guess you forgot to consider the crc_len during processing. /Steve
> 
> In fm10k, crc is always be stripped and pkt_len/data_len carried actual
> data length. So, we needn't add crc_len back here.  This is a little different
> from IXGBE.
Ok, that's fine. /Steve



[dpdk-dev] [PATCH v3 04/16] fm10k: add func to re-allocate mbuf for RX ring

2015-10-29 Thread Liang, Cunming
Hi Mark?


> -Original Message-
> From: Chen, Jing D
> Sent: Thursday, October 29, 2015 1:24 PM
> To: Liang, Cunming; dev at dpdk.org
> Cc: Tao, Zhe; He, Shaopeng; Ananyev, Konstantin; Richardson, Bruce
> Subject: RE: [PATCH v3 04/16] fm10k: add func to re-allocate mbuf for RX ring
> 
> Hi, Steve,
> 
> Best Regards,
> Mark
> 
> 
> > -Original Message-
> > From: Liang, Cunming
> > Sent: Wednesday, October 28, 2015 9:59 PM
> > To: Chen, Jing D; dev at dpdk.org
> > Cc: Tao, Zhe; He, Shaopeng; Ananyev, Konstantin; Richardson, Bruce
> > Subject: Re: [PATCH v3 04/16] fm10k: add func to re-allocate mbuf for RX 
> > ring
> >
> > Hi Mark,
> >
> > On 10/27/2015 5:46 PM, Chen Jing D(Mark) wrote:
> > > From: "Chen Jing D(Mark)" 
> > >
> > > Add function fm10k_rxq_rearm to re-allocate mbuf for used desc
> > > in RX HW ring.
> > >
> > > Signed-off-by: Chen Jing D(Mark) 
> > > ---
> > >   drivers/net/fm10k/fm10k.h  |9 
> > >   drivers/net/fm10k/fm10k_ethdev.c   |3 +
> > >   drivers/net/fm10k/fm10k_rxtx_vec.c |   90
> > 
> > >   3 files changed, 102 insertions(+), 0 deletions(-)
> > [...]
> > > +static inline void
> > > +fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
> > > +{
> > > + int i;
> > > + uint16_t rx_id;
> > > + volatile union fm10k_rx_desc *rxdp;
> > > + struct rte_mbuf **mb_alloc = &rxq->sw_ring[rxq->rxrearm_start];
> > > + struct rte_mbuf *mb0, *mb1;
> > > + __m128i head_off = _mm_set_epi64x(
> > > + RTE_PKTMBUF_HEADROOM +
> > FM10K_RX_DATABUF_ALIGN - 1,
> > > + RTE_PKTMBUF_HEADROOM +
> > FM10K_RX_DATABUF_ALIGN - 1);
> > > + __m128i dma_addr0, dma_addr1;
> > > + /* Rx buffer need to be aligned with 512 byte */
> > > + const __m128i hba_msk = _mm_set_epi64x(0,
> > > + UINT64_MAX - FM10K_RX_DATABUF_ALIGN
> > + 1);
> > > +
> > > + rxdp = rxq->hw_ring + rxq->rxrearm_start;
> > > +
> > > + /* Pull 'n' more MBUFs into the software ring */
> > > + if (rte_mempool_get_bulk(rxq->mp,
> > > +  (void *)mb_alloc,
> > > +  RTE_FM10K_RXQ_REARM_THRESH) < 0) {
> > Here's one potential issue when the failure happens. As tail won't
> > update, the head will equal to tail in the end. HW won't write back
> > anyway, however the SW recv_raw_pkts_vec only check DD bit, the old
> > 'dirty' descriptor(DD bit is not clean) will be taken and continue move
> > forward to check the next which even beyond the tail. I'm sorry didn't
> > catch it on the first time. /Steve
> 
> I have a different view on this. In case mbuf allocation always failed and 
> tail
> equaled to head,
> then HW will stop to send new packet to HW ring, as you pointed out. Then,
> when
> Mbuf can be allocated, this function will refill HW ring and update tail. 
We can't guarantee it successful to recover and allocates new mbuf before the 
polling SW already move beyond the un-rearmed dirty entry. 
So, HW
> will
> resume to fill packet to HW ring. Receive functions will continue to work.
The point is HW is pending on that moment, but polling receive function won't 
wait, it just read next DD, but the value is 1 which hasn't cleared.
> Anything I missed?
> 
> > > + rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed
> > +=
> > > + RTE_FM10K_RXQ_REARM_THRESH;
> > > + return;
> > > + }
> > > +
> > > +



[dpdk-dev] [PATCH v3 0/2] i40e: Fix the statistics issue of i40e

2015-10-29 Thread Thomas Monjalon
Hi,

> Xutao Sun (2):
>   i40e: Fix the statistics issue of i40e
>   doc: update release notes

It is not needed to have a separate commit for the documentation in this case.
Thanks for considering it next time :)



[dpdk-dev] [PATCH v3 0/2] i40e: Fix the statistics issue of i40e

2015-10-29 Thread Sun, Xutao
Hi, Thomas

> -Original Message-
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Thursday, October 29, 2015 4:19 PM
> To: Sun, Xutao
> Cc: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH v3 0/2] i40e: Fix the statistics issue of i40e
> 
> Hi,
> 
> > Xutao Sun (2):
> >   i40e: Fix the statistics issue of i40e
> >   doc: update release notes
> 
> It is not needed to have a separate commit for the documentation in this
> case.
> Thanks for considering it next time :)

OK. Thank you for your advice.

Thanks,
Xutao


[dpdk-dev] [PATCH v3 04/16] fm10k: add func to re-allocate mbuf for RX ring

2015-10-29 Thread Chen, Jing D
Hi, Steve,

Best Regards,
Mark


> -Original Message-
> From: Liang, Cunming
> Sent: Thursday, October 29, 2015 4:15 PM
> To: Chen, Jing D; dev at dpdk.org
> Cc: Tao, Zhe; He, Shaopeng; Ananyev, Konstantin; Richardson, Bruce
> Subject: RE: [PATCH v3 04/16] fm10k: add func to re-allocate mbuf for RX ring
> 
> Hi Mark?
> 
> 
> > -Original Message-
> > From: Chen, Jing D
> > Sent: Thursday, October 29, 2015 1:24 PM
> > To: Liang, Cunming; dev at dpdk.org
> > Cc: Tao, Zhe; He, Shaopeng; Ananyev, Konstantin; Richardson, Bruce
> > Subject: RE: [PATCH v3 04/16] fm10k: add func to re-allocate mbuf for RX
> ring
> >
> > Hi, Steve,
> >
> > Best Regards,
> > Mark
> >
> >
> > > -Original Message-
> > > From: Liang, Cunming
> > > Sent: Wednesday, October 28, 2015 9:59 PM
> > > To: Chen, Jing D; dev at dpdk.org
> > > Cc: Tao, Zhe; He, Shaopeng; Ananyev, Konstantin; Richardson, Bruce
> > > Subject: Re: [PATCH v3 04/16] fm10k: add func to re-allocate mbuf for RX
> ring
> > >
> > > Hi Mark,
> > >
> > > On 10/27/2015 5:46 PM, Chen Jing D(Mark) wrote:
> > > > From: "Chen Jing D(Mark)" 
> > > >
> > > > Add function fm10k_rxq_rearm to re-allocate mbuf for used desc
> > > > in RX HW ring.
> > > >
> > > > Signed-off-by: Chen Jing D(Mark) 
> > > > ---
> > > >   drivers/net/fm10k/fm10k.h  |9 
> > > >   drivers/net/fm10k/fm10k_ethdev.c   |3 +
> > > >   drivers/net/fm10k/fm10k_rxtx_vec.c |   90
> > > 
> > > >   3 files changed, 102 insertions(+), 0 deletions(-)
> > > [...]
> > > > +static inline void
> > > > +fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
> > > > +{
> > > > +   int i;
> > > > +   uint16_t rx_id;
> > > > +   volatile union fm10k_rx_desc *rxdp;
> > > > +   struct rte_mbuf **mb_alloc = &rxq->sw_ring[rxq->rxrearm_start];
> > > > +   struct rte_mbuf *mb0, *mb1;
> > > > +   __m128i head_off = _mm_set_epi64x(
> > > > +   RTE_PKTMBUF_HEADROOM +
> > > FM10K_RX_DATABUF_ALIGN - 1,
> > > > +   RTE_PKTMBUF_HEADROOM +
> > > FM10K_RX_DATABUF_ALIGN - 1);
> > > > +   __m128i dma_addr0, dma_addr1;
> > > > +   /* Rx buffer need to be aligned with 512 byte */
> > > > +   const __m128i hba_msk = _mm_set_epi64x(0,
> > > > +   UINT64_MAX - FM10K_RX_DATABUF_ALIGN
> > > + 1);
> > > > +
> > > > +   rxdp = rxq->hw_ring + rxq->rxrearm_start;
> > > > +
> > > > +   /* Pull 'n' more MBUFs into the software ring */
> > > > +   if (rte_mempool_get_bulk(rxq->mp,
> > > > +(void *)mb_alloc,
> > > > +RTE_FM10K_RXQ_REARM_THRESH) < 0) {
> > > Here's one potential issue when the failure happens. As tail won't
> > > update, the head will equal to tail in the end. HW won't write back
> > > anyway, however the SW recv_raw_pkts_vec only check DD bit, the old
> > > 'dirty' descriptor(DD bit is not clean) will be taken and continue move
> > > forward to check the next which even beyond the tail. I'm sorry didn't
> > > catch it on the first time. /Steve
> >
> > I have a different view on this. In case mbuf allocation always failed and 
> > tail
> > equaled to head,
> > then HW will stop to send new packet to HW ring, as you pointed out. Then,
> > when
> > Mbuf can be allocated, this function will refill HW ring and update tail.
> We can't guarantee it successful to recover and allocates new mbuf before
> the polling SW already move beyond the un-rearmed dirty entry.
> So, HW

Thanks! I got you. I'll change accordingly.

> > will
> > resume to fill packet to HW ring. Receive functions will continue to work.
> The point is HW is pending on that moment, but polling receive function
> won't wait, it just read next DD, but the value is 1 which hasn't cleared.
> > Anything I missed?
> >
> > > > +   rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed
> > > +=
> > > > +   RTE_FM10K_RXQ_REARM_THRESH;
> > > > +   return;
> > > > +   }
> > > > +
> > > > +



[dpdk-dev] [PATCH v3 3/3] doc: update release notes and testpmd guide

2015-10-29 Thread Zhang, Helin


> -Original Message-
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Thursday, October 29, 2015 3:48 PM
> To: Zhang, Helin
> Cc: dev at dpdk.org; Pei, Yulong
> Subject: Re: [dpdk-dev] [PATCH v3 3/3] doc: update release notes and testpmd
> guide
> 
> Hi Helin,
> 
> Please avoid making a commit for doc only.
> These changes are related to some code changes and must be atomic.
> For next time, please update the release notes in the patch adding the feature
> (i40e here) and the testpmd doc in the testpmd patch.
Good to learn that! Thank you for the guidance!

Helin

> 
> Thanks for explaining the logic to others
> 
> 2015-10-29 14:18, Helin Zhang:
> > Update release notes with the newly added feature of selecting
> > different GRE key length for input set, and testpmd guide with newly
> > added commands for that.
> >
> > Signed-off-by: Helin Zhang 



[dpdk-dev] [PATCH] virtio: fix size of mac_addrs array in virtio ports

2015-10-29 Thread David Marchand
From: Ivan Boule 

Make the virtio PMD allocate the array of unicast MAC addresses with
the maximum of entries (VIRTIO_MAX_MAC_ADDRS) that it exports.

Signed-off-by: Ivan Boule 
Signed-off-by: David Marchand 
---
 drivers/net/virtio/virtio_ethdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 12fcc23..79a97c3 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1175,11 +1175,11 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
}

/* Allocate memory for storing MAC addresses */
-   eth_dev->data->mac_addrs = rte_zmalloc("virtio", ETHER_ADDR_LEN, 0);
+   eth_dev->data->mac_addrs = rte_zmalloc("virtio", VIRTIO_MAX_MAC_ADDRS * 
ETHER_ADDR_LEN, 0);
if (eth_dev->data->mac_addrs == NULL) {
PMD_INIT_LOG(ERR,
"Failed to allocate %d bytes needed to store MAC 
addresses",
-   ETHER_ADDR_LEN);
+   VIRTIO_MAX_MAC_ADDRS * ETHER_ADDR_LEN);
return -ENOMEM;
}

-- 
1.9.1



[dpdk-dev] [PATCH] app/testpmd: fix icmp echo tx queues

2015-10-29 Thread David Marchand
icmp echo forward engine relies on the core rank rather than the number of
queues available.
This fix is still wrong, because if we set a nb-rxq > nb-txq, then we will use
an invalid txq, but with this, we are aligned on other fwd engines.

Signed-off-by: David Marchand 
---
 app/test-pmd/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index cf2aa6e..314215c 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1278,7 +1278,7 @@ icmp_echo_config_setup(void)
fs->rx_port = fwd_ports_ids[rxp];
fs->rx_queue = rxq;
fs->tx_port = fs->rx_port;
-   fs->tx_queue = lc_id;
+   fs->tx_queue = rxq;
fs->peer_addr = fs->tx_port;
if (verbose_level > 0)
printf("  stream=%d port=%d rxq=%d txq=%d\n",
-- 
1.9.1



[dpdk-dev] [PATCH] ixgbe: remove useless fields in tx_offload on TCP checksum request

2015-10-29 Thread David Marchand
From: Didier Pallard 

According to Table 7-38: Valid Fields by Offload Option
of Intel ? 82599 10 GbE Controller Datasheet,
L4LEN field is not needed for L4 XSUM computation by the hardware.
So remove l4_len from tx_offload_mask in ixgbe_set_xmit_ctx
function used to build the context transmitted to the hardware.

Signed-off-by: Didier Pallard 
Signed-off-by: David Marchand 
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index a598a72..26bc2a1 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -415,7 +415,6 @@ ixgbe_set_xmit_ctx(struct ixgbe_tx_queue *txq,
mss_l4len_idx |= sizeof(struct tcp_hdr) << 
IXGBE_ADVTXD_L4LEN_SHIFT;
tx_offload_mask.l2_len |= ~0;
tx_offload_mask.l3_len |= ~0;
-   tx_offload_mask.l4_len |= ~0;
break;
case PKT_TX_SCTP_CKSUM:
type_tucmd_mlhl |= IXGBE_ADVTXD_TUCMD_L4T_SCTP |
-- 
1.9.1



[dpdk-dev] [PATCH v2 00/10] enable DCB feature on Intel XL710/X710 NIC

2015-10-29 Thread Jingjing Wu
The patch set enables DCB feature on Intel XL710/X710 NICs, including:
  - Receive queue classification based on traffic class
  - Round Robin ETS schedule (rx and tx).
  - Priority flow control
To make the testpmd and ethdev lib more generic on DCB feature,
this patch set also
  - adds a new API to get DCB related information on NICs.
  - changes the DCB test forwarding in testpmd to be on traffic class.
  - move specific validation from lib and application to drivers. 
Additionally, this patch set also corrects some coding style issues.

v2 changes:
 - add a command in testpmd to display dcb info
 - update testpmd guide and release note

Jingjing Wu (10):
  ethdev: rename dcb_queue to dcb_tc in dcb config struct
  ethdev: move the multi-queue checking to specific drivers
  i40e: enable DCB feature on FVL
  ixgbe: enable DCB+RSS multi-queue mode
  ethdev: new API to get dcb related information
  ixgbe: get_dcb_info ops implement
  i40e: get_dcb_info ops implement
  app/testpmd: set up DCB forwarding based on traffic class
  app/testpmd: add command to display DCB info
  doc: update testpmd guide and release note

 app/test-pmd/cmdline.c  |  54 ++-
 app/test-pmd/config.c   | 202 +-
 app/test-pmd/testpmd.c  | 151 
 app/test-pmd/testpmd.h  |  24 +-
 doc/guides/rel_notes/release_2_2.rst|   6 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  12 +-
 drivers/net/e1000/igb_ethdev.c  |  84 +++-
 drivers/net/i40e/i40e_ethdev.c  | 574 +++-
 drivers/net/i40e/i40e_ethdev.h  |  14 +
 drivers/net/i40e/i40e_rxtx.c|  32 +-
 drivers/net/i40e/i40e_rxtx.h|   2 +
 drivers/net/ixgbe/ixgbe_ethdev.c| 251 
 drivers/net/ixgbe/ixgbe_ethdev.h|   3 +
 drivers/net/ixgbe/ixgbe_rxtx.c  |  58 +--
 examples/vmdq_dcb/main.c|   4 +-
 lib/librte_ether/rte_ethdev.c   | 217 +--
 lib/librte_ether/rte_ethdev.h   |  68 +++-
 17 files changed, 1303 insertions(+), 453 deletions(-)

-- 
2.4.0



[dpdk-dev] [PATCH v2 01/10] ethdev: rename dcb_queue to dcb_tc in dcb config struct

2015-10-29 Thread Jingjing Wu
Signed-off-by: Jingjing Wu 
---
 app/test-pmd/testpmd.c |  8 
 drivers/net/ixgbe/ixgbe_rxtx.c | 10 +-
 examples/vmdq_dcb/main.c   |  4 ++--
 lib/librte_ether/rte_ethdev.h  | 14 +++---
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index 2578b6b..8b8eb7d 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -1875,8 +1875,8 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, struct 
dcb_config *dcb_conf)
vmdq_rx_conf.pool_map[i].pools = 1 << (i % 
vmdq_rx_conf.nb_queue_pools);
}
for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++) {
-   vmdq_rx_conf.dcb_queue[i] = i;
-   vmdq_tx_conf.dcb_queue[i] = i;
+   vmdq_rx_conf.dcb_tc[i] = i;
+   vmdq_tx_conf.dcb_tc[i] = i;
}

/*set DCB mode of RX and TX of multiple queues*/
@@ -1906,8 +1906,8 @@ get_eth_dcb_conf(struct rte_eth_conf *eth_conf, struct 
dcb_config *dcb_conf)
tx_conf.nb_tcs = dcb_conf->num_tcs;

for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++){
-   rx_conf.dcb_queue[i] = i;
-   tx_conf.dcb_queue[i] = i;
+   rx_conf.dcb_tc[i] = i;
+   tx_conf.dcb_tc[i] = i;
}
eth_conf->rxmode.mq_mode = ETH_MQ_RX_DCB;
eth_conf->txmode.mq_mode = ETH_MQ_TX_DCB;
diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index a598a72..d331ef5 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -2903,7 +2903,7 @@ ixgbe_vmdq_dcb_configure(struct rte_eth_dev *dev)
 * mapping is done with 3 bits per priority,
 * so shift by i*3 each time
 */
-   queue_mapping |= ((cfg->dcb_queue[i] & 0x07) << (i * 3));
+   queue_mapping |= ((cfg->dcb_tc[i] & 0x07) << (i * 3));

IXGBE_WRITE_REG(hw, IXGBE_RTRUP2TC, queue_mapping);

@@ -3038,7 +3038,7 @@ ixgbe_vmdq_dcb_rx_config(struct rte_eth_dev *dev,
}
/* User Priority to Traffic Class mapping */
for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++) {
-   j = vmdq_rx_conf->dcb_queue[i];
+   j = vmdq_rx_conf->dcb_tc[i];
tc = &dcb_config->tc_config[j];
tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap =
(uint8_t)(1 << j);
@@ -3066,7 +3066,7 @@ ixgbe_dcb_vt_tx_config(struct rte_eth_dev *dev,

/* User Priority to Traffic Class mapping */
for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++) {
-   j = vmdq_tx_conf->dcb_queue[i];
+   j = vmdq_tx_conf->dcb_tc[i];
tc = &dcb_config->tc_config[j];
tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap =
(uint8_t)(1 << j);
@@ -3088,7 +3088,7 @@ ixgbe_dcb_rx_config(struct rte_eth_dev *dev,

/* User Priority to Traffic Class mapping */
for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++) {
-   j = rx_conf->dcb_queue[i];
+   j = rx_conf->dcb_tc[i];
tc = &dcb_config->tc_config[j];
tc->path[IXGBE_DCB_RX_CONFIG].up_to_tc_bitmap =
(uint8_t)(1 << j);
@@ -3109,7 +3109,7 @@ ixgbe_dcb_tx_config(struct rte_eth_dev *dev,

/* User Priority to Traffic Class mapping */
for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++) {
-   j = tx_conf->dcb_queue[i];
+   j = tx_conf->dcb_tc[i];
tc = &dcb_config->tc_config[j];
tc->path[IXGBE_DCB_TX_CONFIG].up_to_tc_bitmap =
(uint8_t)(1 << j);
diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c
index c31c2ce..b90ac28 100644
--- a/examples/vmdq_dcb/main.c
+++ b/examples/vmdq_dcb/main.c
@@ -107,7 +107,7 @@ static const struct rte_eth_conf vmdq_dcb_conf_default = {
.default_pool = 0,
.nb_pool_maps = 0,
.pool_map = {{0, 0},},
-   .dcb_queue = {0},
+   .dcb_tc = {0},
},
},
 };
@@ -144,7 +144,7 @@ get_eth_conf(struct rte_eth_conf *eth_conf, enum 
rte_eth_nb_pools num_pools)
conf.pool_map[i].pools = 1 << (i % num_pools);
}
for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++){
-   conf.dcb_queue[i] = (uint8_t)(i % (NUM_QUEUES/num_pools));
+   conf.dcb_tc[i] = (uint8_t)(i % (NUM_QUEUES/num_pools));
}
(void)(rte_memcpy(eth_conf, &vmdq_dcb_conf_default, sizeof(*eth_conf)));
(void)(rte_memcpy(ð_conf->rx_adv_conf.vmdq_dcb_conf, &conf,
diff --git a/lib/librte_ether/rt

[dpdk-dev] [PATCH v2 02/10] ethdev: move the multi-queue checking to specific drivers

2015-10-29 Thread Jingjing Wu
Differnet NIC has its specific constraint on the multi-queue
configuration, so move the checking from ethdev lib to drivers.

Signed-off-by: Jingjing Wu 
---
 drivers/net/e1000/igb_ethdev.c   |  84 -
 drivers/net/ixgbe/ixgbe_ethdev.c | 171 +
 drivers/net/ixgbe/ixgbe_ethdev.h |   3 +
 lib/librte_ether/rte_ethdev.c| 199 ---
 4 files changed, 257 insertions(+), 200 deletions(-)

diff --git a/drivers/net/e1000/igb_ethdev.c b/drivers/net/e1000/igb_ethdev.c
index 848ef6e..d9c13d9 100644
--- a/drivers/net/e1000/igb_ethdev.c
+++ b/drivers/net/e1000/igb_ethdev.c
@@ -866,16 +866,98 @@ rte_igbvf_pmd_init(const char *name __rte_unused, const 
char *params __rte_unuse
 }

 static int
+igb_check_mq_mode(struct rte_eth_dev *dev)
+{
+   enum rte_eth_rx_mq_mode rx_mq_mode = dev->data->dev_conf.rxmode.mq_mode;
+   enum rte_eth_tx_mq_mode tx_mq_mode = dev->data->dev_conf.txmode.mq_mode;
+   uint16_t nb_rx_q = dev->data->nb_rx_queues;
+   uint16_t nb_tx_q = dev->data->nb_rx_queues;
+
+   if ((rx_mq_mode & ETH_MQ_RX_DCB_FLAG) ||
+   tx_mq_mode == ETH_MQ_TX_DCB ||
+   tx_mq_mode == ETH_MQ_TX_VMDQ_DCB) {
+   PMD_INIT_LOG(ERR, "DCB mode is not supported.");
+   return -EINVAL;
+   }
+   if (RTE_ETH_DEV_SRIOV(dev).active != 0) {
+   /* Check multi-queue mode.
+* To no break software we accept ETH_MQ_RX_NONE as this might
+* be used to turn off VLAN filter.
+*/
+
+   if (rx_mq_mode == ETH_MQ_RX_NONE ||
+   rx_mq_mode == ETH_MQ_RX_VMDQ_ONLY) {
+   dev->data->dev_conf.rxmode.mq_mode = 
ETH_MQ_RX_VMDQ_ONLY;
+   RTE_ETH_DEV_SRIOV(dev).nb_q_per_pool = 1;
+   } else {
+   /* Only support one queue on VFs.
+* RSS together with SRIOV is not supported.
+*/
+   PMD_INIT_LOG(ERR, "SRIOV is active,"
+   " wrong mq_mode rx %d.",
+   rx_mq_mode);
+   return -EINVAL;
+   }
+   /* TX mode is not used here, so mode might be ignored.*/
+   if (tx_mq_mode != ETH_MQ_TX_VMDQ_ONLY) {
+   /* SRIOV only works in VMDq enable mode */
+   PMD_INIT_LOG(WARNING, "SRIOV is active,"
+   " TX mode %d is not supported. "
+   " Driver will behave as %d mode.",
+   tx_mq_mode, ETH_MQ_TX_VMDQ_ONLY);
+   }
+
+   /* check valid queue number */
+   if ((nb_rx_q > 1) || (nb_tx_q > 1)) {
+   PMD_INIT_LOG(ERR, "SRIOV is active,"
+   " only support one queue on VFs.");
+   return -EINVAL;
+   }
+   } else {
+   /* To no break software that set invalid mode, only display
+* warning if invalid mode is used.
+*/
+   if (rx_mq_mode != ETH_MQ_RX_NONE &&
+   rx_mq_mode != ETH_MQ_RX_VMDQ_ONLY &&
+   rx_mq_mode != ETH_MQ_RX_RSS) {
+   /* RSS together with VMDq not supported*/
+   PMD_INIT_LOG(ERR, "RX mode %d is not supported.",
+rx_mq_mode);
+   return -EINVAL;
+   }
+
+   if (tx_mq_mode != ETH_MQ_TX_NONE &&
+   tx_mq_mode != ETH_MQ_TX_VMDQ_ONLY) {
+   PMD_INIT_LOG(WARNING, "TX mode %d is not supported."
+   " Due to txmode is meaningless in this"
+   " driver, just ignore.",
+   tx_mq_mode);
+   }
+   }
+   return 0;
+}
+
+static int
 eth_igb_configure(struct rte_eth_dev *dev)
 {
struct e1000_interrupt *intr =
E1000_DEV_PRIVATE_TO_INTR(dev->data->dev_private);
+   int ret;

PMD_INIT_FUNC_TRACE();
+
+   /* multipe queue mode checking */
+   ret  = igb_check_mq_mode(dev);
+   if (ret != 0) {
+   PMD_DRV_LOG(ERR, "igb_check_mq_mode fails with %d.",
+   ret);
+   return ret;
+   }
+
intr->flags |= E1000_FLAG_NEED_LINK_UPDATE;
PMD_INIT_FUNC_TRACE();

-   return (0);
+   return 0;
 }

 static int
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ec2918c..a7dca55 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -1636,14 +1636,185 @@ ixgbe_vmdq_vlan_hw_filter_enable(struct rte_eth_dev 
*dev)
 }

 static int
+ixgbe_check_vf_rss_rxq_num(struct rte_eth_dev 

[dpdk-dev] [PATCH v2 03/10] i40e: enable DCB feature on FVL

2015-10-29 Thread Jingjing Wu
This patch enables DCB feature on Intel XL710/X710 NICs. It includes:
  Receive queue classification based on traffic class
  Round Robin ETS schedule (rx and tx)
  Priority flow control

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/i40e_ethdev.c | 532 -
 drivers/net/i40e/i40e_ethdev.h |  14 ++
 drivers/net/i40e/i40e_rxtx.c   |  32 ++-
 drivers/net/i40e/i40e_rxtx.h   |   2 +
 4 files changed, 566 insertions(+), 14 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 2dd9fdc..7db1de9 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -56,6 +56,7 @@
 #include "base/i40e_adminq_cmd.h"
 #include "base/i40e_type.h"
 #include "base/i40e_register.h"
+#include "base/i40e_dcb.h"
 #include "i40e_ethdev.h"
 #include "i40e_rxtx.h"
 #include "i40e_pf.h"
@@ -113,6 +114,10 @@
 #define I40E_PRTTSYN_TSYNENA  0x8000
 #define I40E_PRTTSYN_TSYNTYPE 0x0e00

+#define I40E_MAX_PERCENT100
+#define I40E_DEFAULT_DCB_APP_NUM1
+#define I40E_DEFAULT_DCB_APP_PRIO   3
+
 static int eth_i40e_dev_init(struct rte_eth_dev *eth_dev);
 static int eth_i40e_dev_uninit(struct rte_eth_dev *eth_dev);
 static int i40e_dev_configure(struct rte_eth_dev *dev);
@@ -166,6 +171,8 @@ static int i40e_pf_parameter_init(struct rte_eth_dev *dev);
 static int i40e_pf_setup(struct i40e_pf *pf);
 static int i40e_dev_rxtx_init(struct i40e_pf *pf);
 static int i40e_vmdq_setup(struct rte_eth_dev *dev);
+static int i40e_dcb_init_configure(struct rte_eth_dev *dev, bool sw_dcb);
+static int i40e_dcb_setup(struct rte_eth_dev *dev);
 static void i40e_stat_update_32(struct i40e_hw *hw, uint32_t reg,
bool offset_loaded, uint64_t *offset, uint64_t *stat);
 static void i40e_stat_update_48(struct i40e_hw *hw,
@@ -469,11 +476,6 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
 ((hw->nvm.version >> 4) & 0xff),
 (hw->nvm.version & 0xf), hw->nvm.eetrack);

-   /* Disable LLDP */
-   ret = i40e_aq_stop_lldp(hw, true, NULL);
-   if (ret != I40E_SUCCESS) /* Its failure can be ignored */
-   PMD_INIT_LOG(INFO, "Failed to stop lldp");
-
/* Clear PXE mode */
i40e_clear_pxe_mode(hw);

@@ -588,6 +590,13 @@ eth_i40e_dev_init(struct rte_eth_dev *dev)
/* initialize mirror rule list */
TAILQ_INIT(&pf->mirror_list);

+   /* Init dcb to sw mode by default */
+   ret = i40e_dcb_init_configure(dev, TRUE);
+   if (ret != I40E_SUCCESS) {
+   PMD_INIT_LOG(INFO, "Failed to init dcb.");
+   pf->flags &= ~I40E_FLAG_DCB;
+   }
+
return 0;

 err_mac_alloc:
@@ -672,7 +681,7 @@ i40e_dev_configure(struct rte_eth_dev *dev)
 {
struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
enum rte_eth_rx_mq_mode mq_mode = dev->data->dev_conf.rxmode.mq_mode;
-   int ret;
+   int i, ret;

if (dev->data->dev_conf.fdir_conf.mode == RTE_FDIR_MODE_PERFECT) {
ret = i40e_fdir_setup(pf);
@@ -709,8 +718,27 @@ i40e_dev_configure(struct rte_eth_dev *dev)
if (ret)
goto err;
}
+
+   if (mq_mode & ETH_MQ_RX_DCB_FLAG) {
+   ret = i40e_dcb_setup(dev);
+   if (ret) {
+   PMD_DRV_LOG(ERR, "failed to configure DCB.");
+   goto err_dcb;
+   }
+   }
+
return 0;
+
+err_dcb:
+   /* need to release vmdq resource if exists */
+   for (i = 0; i < pf->nb_cfg_vmdq_vsi; i++) {
+   i40e_vsi_release(pf->vmdq[i].vsi);
+   pf->vmdq[i].vsi = NULL;
+   }
+   rte_free(pf->vmdq);
+   pf->vmdq = NULL;
 err:
+   /* need to release fdir resource if exists */
i40e_fdir_teardown(pf);
return ret;
 }
@@ -2313,6 +2341,9 @@ i40e_pf_parameter_init(struct rte_eth_dev *dev)
 */
}

+   if (hw->func_caps.dcb)
+   pf->flags |= I40E_FLAG_DCB;
+
if (sum_vsis > pf->max_num_vsi ||
sum_queues > hw->func_caps.num_rx_qp) {
PMD_INIT_LOG(ERR, "VSI/QUEUE setting can't be satisfied");
@@ -2718,7 +2749,7 @@ i40e_vsi_config_tc_queue_mapping(struct i40e_vsi *vsi,
 struct i40e_aqc_vsi_properties_data *info,
 uint8_t enabled_tcmap)
 {
-   int ret, total_tc = 0, i;
+   int ret, i, total_tc = 0;
uint16_t qpnum_per_tc, bsf, qp_idx;

ret = validate_tcmap_parameter(vsi, enabled_tcmap);
@@ -5269,11 +5300,6 @@ i40e_pf_config_mq_rx(struct i40e_pf *pf)
int ret = 0;
enum rte_eth_rx_mq_mode mq_mode = pf->dev_data->dev_conf.rxmode.mq_mode;

-   if (mq_mode & ETH_MQ_RX_DCB_FLAG) {
-   PMD_INIT_LOG(ERR, "i40e doesn't support DCB yet");
-   return -ENOTSUP;
-   }
-
/* RSS setup */
if (mq_mode & ETH_MQ_RX_RSS_FLA

[dpdk-dev] [PATCH v2 04/10] ixgbe: enable DCB+RSS multi-queue mode

2015-10-29 Thread Jingjing Wu
This patch enables DCB+RSS multi-queue mode, and also fix some coding
style.

Signed-off-by: Jingjing Wu 
---
 drivers/net/ixgbe/ixgbe_rxtx.c | 48 +-
 1 file changed, 29 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_rxtx.c b/drivers/net/ixgbe/ixgbe_rxtx.c
index d331ef5..1dc05f0 100644
--- a/drivers/net/ixgbe/ixgbe_rxtx.c
+++ b/drivers/net/ixgbe/ixgbe_rxtx.c
@@ -3144,9 +3144,13 @@ ixgbe_dcb_rx_hw_config(struct ixgbe_hw *hw,
reg = (reg & ~IXGBE_MRQC_MRQE_MASK) |
IXGBE_MRQC_VMDQRT4TCEN;
else {
+   /* no matter the mode is DCB or DCB_RSS, just
+* set the MRQE to RSSXTCEN. RSS is controlled
+* by RSS_FIELD
+*/
IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, 0);
reg = (reg & ~IXGBE_MRQC_MRQE_MASK) |
-   IXGBE_MRQC_RT4TCEN;
+   IXGBE_MRQC_RTRSS4TCEN;
}
}
if (dcb_config->num_tcs.pg_tcs == 8) {
@@ -3156,7 +3160,7 @@ ixgbe_dcb_rx_hw_config(struct ixgbe_hw *hw,
else {
IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, 0);
reg = (reg & ~IXGBE_MRQC_MRQE_MASK) |
-   IXGBE_MRQC_RT8TCEN;
+   IXGBE_MRQC_RTRSS8TCEN;
}
}

@@ -3261,16 +3265,17 @@ ixgbe_dcb_hw_configure(struct rte_eth_dev *dev,
 *get dcb and VT rx configuration parameters
 *from rte_eth_conf
 */
-   ixgbe_vmdq_dcb_rx_config(dev,dcb_config);
+   ixgbe_vmdq_dcb_rx_config(dev, dcb_config);
/*Configure general VMDQ and DCB RX parameters*/
ixgbe_vmdq_dcb_configure(dev);
}
break;
case ETH_MQ_RX_DCB:
+   case ETH_MQ_RX_DCB_RSS:
dcb_config->vt_mode = false;
config_dcb_rx = DCB_RX_CONFIG;
/* Get dcb TX configuration parameters from rte_eth_conf */
-   ixgbe_dcb_rx_config(dev,dcb_config);
+   ixgbe_dcb_rx_config(dev, dcb_config);
/*Configure general DCB RX parameters*/
ixgbe_dcb_rx_hw_config(hw, dcb_config);
break;
@@ -3292,7 +3297,7 @@ ixgbe_dcb_hw_configure(struct rte_eth_dev *dev,
dcb_config->vt_mode = false;
config_dcb_tx = DCB_TX_CONFIG;
/*get DCB TX configuration parameters from rte_eth_conf*/
-   ixgbe_dcb_tx_config(dev,dcb_config);
+   ixgbe_dcb_tx_config(dev, dcb_config);
/*Configure general DCB TX parameters*/
ixgbe_dcb_tx_hw_config(hw, dcb_config);
break;
@@ -3433,14 +3438,15 @@ void ixgbe_configure_dcb(struct rte_eth_dev *dev)

/* check support mq_mode for DCB */
if ((dev_conf->rxmode.mq_mode != ETH_MQ_RX_VMDQ_DCB) &&
-   (dev_conf->rxmode.mq_mode != ETH_MQ_RX_DCB))
+   (dev_conf->rxmode.mq_mode != ETH_MQ_RX_DCB) &&
+   (dev_conf->rxmode.mq_mode != ETH_MQ_RX_DCB_RSS))
return;

if (dev->data->nb_rx_queues != ETH_DCB_NUM_QUEUES)
return;

/** Configure DCB hardware **/
-   ixgbe_dcb_hw_configure(dev,dcb_cfg);
+   ixgbe_dcb_hw_configure(dev, dcb_cfg);

return;
 }
@@ -3682,21 +3688,25 @@ ixgbe_dev_mq_rx_configure(struct rte_eth_dev *dev)
 * any DCB/RSS w/o VMDq multi-queue setting
 */
switch (dev->data->dev_conf.rxmode.mq_mode) {
-   case ETH_MQ_RX_RSS:
-   ixgbe_rss_configure(dev);
-   break;
+   case ETH_MQ_RX_RSS:
+   case ETH_MQ_RX_DCB_RSS:
+   case ETH_MQ_RX_VMDQ_RSS:
+   ixgbe_rss_configure(dev);
+   break;

-   case ETH_MQ_RX_VMDQ_DCB:
-   ixgbe_vmdq_dcb_configure(dev);
-   break;
+   case ETH_MQ_RX_VMDQ_DCB:
+   ixgbe_vmdq_dcb_configure(dev);
+   break;

-   case ETH_MQ_RX_VMDQ_ONLY:
-   ixgbe_vmdq_rx_hw_configure(dev);
-   break;
+   case ETH_MQ_RX_VMDQ_ONLY:
+   ixgbe_vmdq_rx_hw_configure(dev);
+   break;

-   case ETH_MQ_RX_NONE:
-   /* if mq_mode is none, disable rss mode.*/
-

[dpdk-dev] [PATCH v2 06/10] ixgbe: get_dcb_info ops implement

2015-10-29 Thread Jingjing Wu
This patch implements the get_dcb_info ops in ixgbe driver.

Signed-off-by: Jingjing Wu 
---
 drivers/net/ixgbe/ixgbe_ethdev.c | 80 
 1 file changed, 80 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index a7dca55..fc5da21 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -304,6 +304,8 @@ static int ixgbevf_dev_set_mtu(struct rte_eth_dev *dev, 
uint16_t mtu);
 static int ixgbe_dev_set_mc_addr_list(struct rte_eth_dev *dev,
  struct ether_addr *mc_addr_set,
  uint32_t nb_mc_addr);
+static int ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
+  struct rte_eth_dcb_info *dcb_info);

 static int ixgbe_get_reg_length(struct rte_eth_dev *dev);
 static int ixgbe_get_regs(struct rte_eth_dev *dev,
@@ -465,6 +467,7 @@ static const struct eth_dev_ops ixgbe_eth_dev_ops = {
.get_eeprom_length= ixgbe_get_eeprom_length,
.get_eeprom   = ixgbe_get_eeprom,
.set_eeprom   = ixgbe_set_eeprom,
+   .get_dcb_info = ixgbe_dev_get_dcb_info,
 };

 /*
@@ -5644,6 +5647,83 @@ ixgbe_set_eeprom(struct rte_eth_dev *dev,
return eeprom->ops.write_buffer(hw,  first, length, data);
 }

+static int
+ixgbe_dev_get_dcb_info(struct rte_eth_dev *dev,
+   struct rte_eth_dcb_info *dcb_info)
+{
+   struct ixgbe_dcb_config *dcb_config =
+   IXGBE_DEV_PRIVATE_TO_DCB_CFG(dev->data->dev_private);
+   struct ixgbe_dcb_tc_config *tc;
+   uint8_t i, j;
+
+   if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_DCB_FLAG)
+   dcb_info->nb_tcs = dcb_config->num_tcs.pg_tcs;
+   else
+   dcb_info->nb_tcs = 1;
+
+   if (dcb_config->vt_mode) { /* vt is enabled*/
+   struct rte_eth_vmdq_dcb_conf *vmdq_rx_conf =
+   &dev->data->dev_conf.rx_adv_conf.vmdq_dcb_conf;
+   for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
+   dcb_info->prio_tc[i] = vmdq_rx_conf->dcb_tc[i];
+   for (i = 0; i < vmdq_rx_conf->nb_queue_pools; i++) {
+   for (j = 0; j < dcb_info->nb_tcs; j++) {
+   dcb_info->tc_queue.tc_rxq[i][j].base =
+   i * dcb_info->nb_tcs + j;
+   dcb_info->tc_queue.tc_rxq[i][j].nb_queue = 1;
+   dcb_info->tc_queue.tc_txq[i][j].base =
+   i * dcb_info->nb_tcs + j;
+   dcb_info->tc_queue.tc_txq[i][j].nb_queue = 1;
+   }
+   }
+   } else { /* vt is disabled*/
+   struct rte_eth_dcb_rx_conf *rx_conf =
+   &dev->data->dev_conf.rx_adv_conf.dcb_rx_conf;
+   for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++)
+   dcb_info->prio_tc[i] = rx_conf->dcb_tc[i];
+   if (dcb_info->nb_tcs == ETH_4_TCS) {
+   for (i = 0; i < dcb_info->nb_tcs; i++) {
+   dcb_info->tc_queue.tc_rxq[0][i].base = i * 32;
+   dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
+   }
+   dcb_info->tc_queue.tc_txq[0][0].base = 0;
+   dcb_info->tc_queue.tc_txq[0][1].base = 64;
+   dcb_info->tc_queue.tc_txq[0][2].base = 96;
+   dcb_info->tc_queue.tc_txq[0][3].base = 112;
+   dcb_info->tc_queue.tc_txq[0][0].nb_queue = 64;
+   dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
+   dcb_info->tc_queue.tc_txq[0][2].nb_queue = 16;
+   dcb_info->tc_queue.tc_txq[0][3].nb_queue = 16;
+   } else if (dcb_info->nb_tcs == ETH_8_TCS) {
+   for (i = 0; i < dcb_info->nb_tcs; i++) {
+   dcb_info->tc_queue.tc_rxq[0][i].base = i * 16;
+   dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 16;
+   }
+   dcb_info->tc_queue.tc_txq[0][0].base = 0;
+   dcb_info->tc_queue.tc_txq[0][1].base = 32;
+   dcb_info->tc_queue.tc_txq[0][2].base = 64;
+   dcb_info->tc_queue.tc_txq[0][3].base = 80;
+   dcb_info->tc_queue.tc_txq[0][4].base = 96;
+   dcb_info->tc_queue.tc_txq[0][5].base = 104;
+   dcb_info->tc_queue.tc_txq[0][6].base = 112;
+   dcb_info->tc_queue.tc_txq[0][7].base = 120;
+   dcb_info->tc_queue.tc_txq[0][0].nb_queue = 32;
+   dcb_info->tc_queue.tc_txq[0][1].nb_queue = 32;
+   dcb_info->tc_queue.

[dpdk-dev] [PATCH v2 05/10] ethdev: new API to get dcb related information

2015-10-29 Thread Jingjing Wu
This patch adds one new API to get dcb related info.
  rte_eth_dev_get_dcb_info

Signed-off-by: Jingjing Wu 
---
 lib/librte_ether/rte_ethdev.c | 18 +++
 lib/librte_ether/rte_ethdev.h | 54 +++
 2 files changed, 72 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index c7247c3..721cef6 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -3143,3 +3143,21 @@ rte_eth_dev_set_eeprom(uint8_t port_id, struct 
rte_dev_eeprom_info *info)
FUNC_PTR_OR_ERR_RET(*dev->dev_ops->set_eeprom, -ENOTSUP);
return (*dev->dev_ops->set_eeprom)(dev, info);
 }
+
+int
+rte_eth_dev_get_dcb_info(uint8_t port_id,
+struct rte_eth_dcb_info *dcb_info)
+{
+   struct rte_eth_dev *dev;
+
+   if (!rte_eth_dev_is_valid_port(port_id)) {
+   PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
+   return -ENODEV;
+   }
+
+   dev = &rte_eth_devices[port_id];
+   memset(dcb_info, 0, sizeof(struct rte_eth_dcb_info));
+
+   FUNC_PTR_OR_ERR_RET(*dev->dev_ops->get_dcb_info, -ENOTSUP);
+   return (*dev->dev_ops->get_dcb_info)(dev, dcb_info);
+}
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 377da6a..2e05189 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -854,6 +854,38 @@ struct rte_eth_xstats {
uint64_t value;
 };

+#define ETH_DCB_NUM_TCS8
+#define ETH_MAX_VMDQ_POOL  64
+
+/**
+ * A structure used to get the information of queue and
+ * TC mapping on both TX and RX paths.
+ */
+struct rte_eth_dcb_tc_queue_mapping {
+   /** rx queues assigned to tc per Pool */
+   struct {
+   uint8_t base;
+   uint8_t nb_queue;
+   } tc_rxq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
+   /** rx queues assigned to tc per Pool */
+   struct {
+   uint8_t base;
+   uint8_t nb_queue;
+   } tc_txq[ETH_MAX_VMDQ_POOL][ETH_DCB_NUM_TCS];
+};
+
+/**
+ * A structure used to get the information of DCB.
+ * It includes TC UP mapping and queue TC mapping.
+ */
+struct rte_eth_dcb_info {
+   uint8_t nb_tcs;/**< number of TCs */
+   uint8_t prio_tc[ETH_DCB_NUM_USER_PRIORITIES]; /**< Priority to tc */
+   uint8_t tc_bws[ETH_DCB_NUM_TCS]; /**< TX BW percentage for each TC */
+   /** rx queues assigned to tc */
+   struct rte_eth_dcb_tc_queue_mapping tc_queue;
+};
+
 struct rte_eth_dev;

 struct rte_eth_dev_callback;
@@ -1207,6 +1239,10 @@ typedef int (*eth_filter_ctrl_t)(struct rte_eth_dev *dev,
 void *arg);
 /**< @internal Take operations to assigned filter type on an Ethernet device */

+typedef int (*eth_get_dcb_info)(struct rte_eth_dev *dev,
+struct rte_eth_dcb_info *dcb_info);
+/**< @internal Get dcb information on an Ethernet device */
+
 /**
  * @internal A structure containing the functions exported by an Ethernet 
driver.
  */
@@ -1312,6 +1348,9 @@ struct eth_dev_ops {
eth_timesync_read_rx_timestamp_t timesync_read_rx_timestamp;
/** Read the IEEE1588/802.1AS TX timestamp. */
eth_timesync_read_tx_timestamp_t timesync_read_tx_timestamp;
+
+   /** Get DCB information */
+   eth_get_dcb_info get_dcb_info;
 };

 /**
@@ -3321,6 +3360,21 @@ int rte_eth_dev_filter_ctrl(uint8_t port_id, enum 
rte_filter_type filter_type,
enum rte_filter_op filter_op, void *arg);

 /**
+ * Get DCB information on an Ethernet device.
+ *
+ * @param port_id
+ *   The port identifier of the Ethernet device.
+ * @param dcb_info
+ *   dcb information.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if port identifier is invalid.
+ *   - (-ENOTSUP) if hardware doesn't support.
+ */
+int rte_eth_dev_get_dcb_info(uint8_t port_id,
+struct rte_eth_dcb_info *dcb_info);
+
+/**
  * Add a callback to be called on packet RX on a given port and queue.
  *
  * This API configures a function to be called for each burst of
-- 
2.4.0



[dpdk-dev] [PATCH v2 10/10] doc: update testpmd guide and release note

2015-10-29 Thread Jingjing Wu
Signed-off-by: Jingjing Wu 
---
 doc/guides/rel_notes/release_2_2.rst|  6 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 12 +++-
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/doc/guides/rel_notes/release_2_2.rst 
b/doc/guides/rel_notes/release_2_2.rst
index de6916e..7c0737a 100644
--- a/doc/guides/rel_notes/release_2_2.rst
+++ b/doc/guides/rel_notes/release_2_2.rst
@@ -11,6 +11,12 @@ New Features

 * **Added vhost-user multiple queue support.**

+* **Added i40e DCB support.**
+
+  *  Added support to the i40e driver for DCB on PF.
+  *  Provided new API rte_eth_dev_get_dcb_info to query DCB information.
+  *  Changes the testpmd DCB forwarding stream to make it based on TC.
+

 Resolved Issues
 ---
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst 
b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 71d831b..b7659d0 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -50,10 +50,10 @@ If you type a partial command and hit  you get a 
list of the available

testpmd> show port 

-   info [Mul-choice STRING]: show|clear port info|stats|fdir|stat_qmap X
-   info [Mul-choice STRING]: show|clear port info|stats|fdir|stat_qmap all
-   stats [Mul-choice STRING]: show|clear port info|stats|fdir|stat_qmap X
-   stats [Mul-choice STRING]: show|clear port info|stats|fdir|stat_qmap all
+   info [Mul-choice STRING]: show|clear port 
info|stats|fdir|stat_qmap|dcb_tc X
+   info [Mul-choice STRING]: show|clear port 
info|stats|fdir|stat_qmap|dcb_tc all
+   stats [Mul-choice STRING]: show|clear port 
info|stats|fdir|stat_qmap|dcb_tc X
+   stats [Mul-choice STRING]: show|clear port 
info|stats|fdir|stat_qmap|dcb_tc all
...


@@ -128,7 +128,7 @@ show port

 Display information for a given port or all ports::

-   testpmd> show port (info|stats|fdir|stat_qmap) (port_id|all)
+   testpmd> show port (info|stats|fdir|stat_qmap|dcb_tc) (port_id|all)

 The available information categories are:

@@ -140,6 +140,8 @@ The available information categories are:

 * ``stat_qmap``: Queue statistics mapping.

+* ``dcb_tc``: DCB information such as TC mapping.
+
 For example:

 .. code-block:: console
-- 
2.4.0



[dpdk-dev] [PATCH v2 07/10] i40e: get_dcb_info ops implement

2015-10-29 Thread Jingjing Wu
This patch implements the get_dcb_info ops in i40e driver.

Signed-off-by: Jingjing Wu 
---
 drivers/net/i40e/i40e_ethdev.c | 42 ++
 1 file changed, 42 insertions(+)

diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
index 7db1de9..28f780b 100644
--- a/drivers/net/i40e/i40e_ethdev.c
+++ b/drivers/net/i40e/i40e_ethdev.c
@@ -224,6 +224,8 @@ static int i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
enum rte_filter_type filter_type,
enum rte_filter_op filter_op,
void *arg);
+static int i40e_dev_get_dcb_info(struct rte_eth_dev *dev,
+ struct rte_eth_dcb_info *dcb_info);
 static void i40e_configure_registers(struct i40e_hw *hw);
 static void i40e_hw_init(struct i40e_hw *hw);
 static int i40e_config_qinq(struct i40e_hw *hw, struct i40e_vsi *vsi);
@@ -296,6 +298,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops = {
.timesync_disable = i40e_timesync_disable,
.timesync_read_rx_timestamp   = i40e_timesync_read_rx_timestamp,
.timesync_read_tx_timestamp   = i40e_timesync_read_tx_timestamp,
+   .get_dcb_info = i40e_dev_get_dcb_info,
 };

 static struct eth_driver rte_i40e_pmd = {
@@ -6806,3 +6809,42 @@ i40e_dcb_setup(struct rte_eth_dev *dev)
}
return 0;
 }
+
+static int
+i40e_dev_get_dcb_info(struct rte_eth_dev *dev,
+ struct rte_eth_dcb_info *dcb_info)
+{
+   struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+   struct i40e_hw *hw = I40E_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct i40e_vsi *vsi = pf->main_vsi;
+   struct i40e_dcbx_config *dcb_cfg = &hw->local_dcbx_config;
+   uint16_t bsf, tc_mapping;
+   int i;
+
+   if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_DCB_FLAG)
+   dcb_info->nb_tcs = rte_bsf32(vsi->enabled_tc + 1);
+   else
+   dcb_info->nb_tcs = 1;
+   for (i = 0; i < I40E_MAX_USER_PRIORITY; i++)
+   dcb_info->prio_tc[i] = dcb_cfg->etscfg.prioritytable[i];
+   for (i = 0; i < dcb_info->nb_tcs; i++)
+   dcb_info->tc_bws[i] = dcb_cfg->etscfg.tcbwtable[i];
+
+   for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) {
+   if (vsi->enabled_tc & (1 << i)) {
+   tc_mapping = rte_le_to_cpu_16(vsi->info.tc_mapping[i]);
+   /* only main vsi support multi TCs */
+   dcb_info->tc_queue.tc_rxq[0][i].base =
+   (tc_mapping & I40E_AQ_VSI_TC_QUE_OFFSET_MASK) >>
+   I40E_AQ_VSI_TC_QUE_OFFSET_SHIFT;
+   dcb_info->tc_queue.tc_txq[0][i].base =
+   dcb_info->tc_queue.tc_rxq[0][i].base;
+   bsf = (tc_mapping & I40E_AQ_VSI_TC_QUE_NUMBER_MASK) >>
+   I40E_AQ_VSI_TC_QUE_NUMBER_SHIFT;
+   dcb_info->tc_queue.tc_rxq[0][i].nb_queue = 1 << bsf;
+   dcb_info->tc_queue.tc_txq[0][i].nb_queue =
+   dcb_info->tc_queue.tc_rxq[0][i].nb_queue;
+   }
+   }
+   return 0;
+}
-- 
2.4.0



[dpdk-dev] [PATCH v2 08/10] app/testpmd: set up DCB forwarding based on traffic class

2015-10-29 Thread Jingjing Wu
This patch changes the testpmd DCB forwarding stream to make it
based on traffic class.
It also fixes some coding style issues.

Signed-off-by: Jingjing Wu 
---
 app/test-pmd/cmdline.c |  39 +++-
 app/test-pmd/config.c  | 159 +
 app/test-pmd/testpmd.c | 151 +-
 app/test-pmd/testpmd.h |  23 +--
 4 files changed, 176 insertions(+), 196 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 0f8f48f..2ec855f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -1999,37 +1999,46 @@ cmd_config_dcb_parsed(void *parsed_result,
 __attribute__((unused)) void *data)
 {
struct cmd_config_dcb *res = parsed_result;
-   struct dcb_config dcb_conf;
portid_t port_id = res->port_id;
struct rte_port *port;
+   uint8_t pfc_en;
+   int ret;

port = &ports[port_id];
/** Check if the port is not started **/
if (port->port_status != RTE_PORT_STOPPED) {
-   printf("Please stop port %d first\n",port_id);
+   printf("Please stop port %d first\n", port_id);
return;
}

-   dcb_conf.num_tcs = (enum rte_eth_nb_tcs) res->num_tcs;
-   if ((dcb_conf.num_tcs != ETH_4_TCS) && (dcb_conf.num_tcs != ETH_8_TCS)){
-   printf("The invalid number of traffic class,only 4 or 8 
allowed\n");
+   if ((res->num_tcs != ETH_4_TCS) && (res->num_tcs != ETH_8_TCS)) {
+   printf("The invalid number of traffic class,"
+   " only 4 or 8 allowed.\n");
return;
}

-   /* DCB in VT mode */
-   if (!strncmp(res->vt_en, "on",2))
-   dcb_conf.dcb_mode = DCB_VT_ENABLED;
+   if (nb_fwd_lcores < res->num_tcs) {
+   printf("nb_cores shouldn't be less than number of TCs.\n");
+   return;
+   }
+   if (!strncmp(res->pfc_en, "on", 2))
+   pfc_en = 1;
else
-   dcb_conf.dcb_mode = DCB_ENABLED;
+   pfc_en = 0;

-   if (!strncmp(res->pfc_en, "on",2)) {
-   dcb_conf.pfc_en = 1;
-   }
+   /* DCB in VT mode */
+   if (!strncmp(res->vt_en, "on", 2))
+   ret = init_port_dcb_config(port_id, DCB_VT_ENABLED,
+   (enum rte_eth_nb_tcs)res->num_tcs,
+   pfc_en);
else
-   dcb_conf.pfc_en = 0;
+   ret = init_port_dcb_config(port_id, DCB_ENABLED,
+   (enum rte_eth_nb_tcs)res->num_tcs,
+   pfc_en);
+

-   if (init_port_dcb_config(port_id,&dcb_conf) != 0) {
-   printf("Cannot initialize network ports\n");
+   if (ret != 0) {
+   printf("Cannot initialize network ports.\n");
return;
}

diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index cf2aa6e..11136aa 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -1128,113 +1128,92 @@ rss_fwd_config_setup(void)
}
 }

-/*
- * In DCB and VT on,the mapping of 128 receive queues to 128 transmit queues.
- */
-static void
-dcb_rxq_2_txq_mapping(queueid_t rxq, queueid_t *txq)
-{
-   if(dcb_q_mapping == DCB_4_TCS_Q_MAPPING) {
-
-   if (rxq < 32)
-   /* tc0: 0-31 */
-   *txq = rxq;
-   else if (rxq < 64) {
-   /* tc1: 64-95 */
-   *txq =  (uint16_t)(rxq + 32);
-   }
-   else {
-   /* tc2: 96-111;tc3:112-127 */
-   *txq =  (uint16_t)(rxq/2 + 64);
-   }
-   }
-   else {
-   if (rxq < 16)
-   /* tc0 mapping*/
-   *txq = rxq;
-   else if (rxq < 32) {
-   /* tc1 mapping*/
-*txq = (uint16_t)(rxq + 16);
-   }
-   else if (rxq < 64) {
-   /*tc2,tc3 mapping */
-   *txq =  (uint16_t)(rxq + 32);
-   }
-   else {
-   /* tc4,tc5,tc6 and tc7 mapping */
-   *txq =  (uint16_t)(rxq/2 + 64);
-   }
-   }
-}
-
 /**
- * For the DCB forwarding test, each core is assigned on every port 
multi-transmit
- * queue.
+ * For the DCB forwarding test, each core is assigned on each traffic class.
  *
  * Each core is assigned a multi-stream, each stream being composed of
  * a RX queue to poll on a RX port for input messages, associated with
- * a TX queue of a TX port where to send forwarded packets.
- * All packets received on the RX queue of index "RxQj" of the RX port "RxPi"
- * are sent on the TX queue "TxQl" of the TX port "TxPk" according to the two
- * following rules:
- * In VT mode,
- *- TxPk = (RxPi + 1) if RxPi is even, (RxP

[dpdk-dev] [PATCH v2 09/10] app/testpmd: add command to display DCB info

2015-10-29 Thread Jingjing Wu
This patch adds a command to display DCB info in ports.

Signed-off-by: Jingjing Wu 
---
 app/test-pmd/cmdline.c | 15 ++-
 app/test-pmd/config.c  | 43 +++
 app/test-pmd/testpmd.h |  1 +
 3 files changed, 54 insertions(+), 5 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 2ec855f..bf6b3e4 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -182,7 +182,7 @@ static void cmd_help_long_parsed(void *parsed_result,
"Display:\n"
"\n\n"

-   "show port (info|stats|xstats|fdir|stat_qmap) 
(port_id|all)\n"
+   "show port (info|stats|xstats|fdir|stat_qmap|dcb_tc) 
(port_id|all)\n"
"Display information for port_id, or all.\n\n"

"show port X rss reta (size) (mask0,mask1,...)\n"
@@ -5235,6 +5235,9 @@ static void cmd_showportall_parsed(void *parsed_result,
else if (!strcmp(res->what, "stat_qmap"))
FOREACH_PORT(i, ports)
nic_stats_mapping_display(i);
+   else if (!strcmp(res->what, "dcb_tc"))
+   FOREACH_PORT(i, ports)
+   port_dcb_info_display(i);
 }

 cmdline_parse_token_string_t cmd_showportall_show =
@@ -5244,13 +5247,13 @@ cmdline_parse_token_string_t cmd_showportall_port =
TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, port, "port");
 cmdline_parse_token_string_t cmd_showportall_what =
TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, what,
-"info#stats#xstats#fdir#stat_qmap");
+"info#stats#xstats#fdir#stat_qmap#dcb_tc");
 cmdline_parse_token_string_t cmd_showportall_all =
TOKEN_STRING_INITIALIZER(struct cmd_showportall_result, all, "all");
 cmdline_parse_inst_t cmd_showportall = {
.f = cmd_showportall_parsed,
.data = NULL,
-   .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap all",
+   .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc 
all",
.tokens = {
(void *)&cmd_showportall_show,
(void *)&cmd_showportall_port,
@@ -5288,6 +5291,8 @@ static void cmd_showport_parsed(void *parsed_result,
 fdir_get_infos(res->portnum);
else if (!strcmp(res->what, "stat_qmap"))
nic_stats_mapping_display(res->portnum);
+   else if (!strcmp(res->what, "dcb_tc"))
+   port_dcb_info_display(res->portnum);
 }

 cmdline_parse_token_string_t cmd_showport_show =
@@ -5297,14 +5302,14 @@ cmdline_parse_token_string_t cmd_showport_port =
TOKEN_STRING_INITIALIZER(struct cmd_showport_result, port, "port");
 cmdline_parse_token_string_t cmd_showport_what =
TOKEN_STRING_INITIALIZER(struct cmd_showport_result, what,
-"info#stats#xstats#fdir#stat_qmap");
+"info#stats#xstats#fdir#stat_qmap#dcb_tc");
 cmdline_parse_token_num_t cmd_showport_portnum =
TOKEN_NUM_INITIALIZER(struct cmd_showport_result, portnum, UINT8);

 cmdline_parse_inst_t cmd_showport = {
.f = cmd_showport_parsed,
.data = NULL,
-   .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap X (X = 
port number)",
+   .help_str = "show|clear port info|stats|xstats|fdir|stat_qmap|dcb_tc X 
(X = port number)",
.tokens = {
(void *)&cmd_showport_show,
(void *)&cmd_showport_port,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 11136aa..6d5820a 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2268,3 +2268,46 @@ mcast_addr_remove(uint8_t port_id, struct ether_addr 
*mc_addr)
mcast_addr_pool_remove(port, i);
eth_port_multicast_addr_list_set(port_id);
 }
+
+void
+port_dcb_info_display(uint8_t port_id)
+{
+   struct rte_eth_dcb_info dcb_info;
+   uint16_t i;
+   int ret;
+   static const char *border = "";
+
+   if (port_id_is_invalid(port_id, ENABLED_WARN))
+   return;
+
+   ret = rte_eth_dev_get_dcb_info(port_id, &dcb_info);
+   if (ret) {
+   printf("\n Failed to get dcb infos on port %-2d\n",
+   port_id);
+   return;
+   }
+   printf("\n  %s DCB infos for port %-2d  %s\n", border, port_id, border);
+   printf("  TC NUMBER: %d\n", dcb_info.nb_tcs);
+   printf("\n  TC :");
+   for (i = 0; i < dcb_info.nb_tcs; i++)
+   printf("\t%4d", i);
+   printf("\n  Priority :  ");
+   for (i = 0; i < dcb_info.nb_tcs; i++)
+   printf("\t%4d", dcb_info.prio_tc[i]);
+   printf("\n  BW percent :");
+   for (i = 0; i < dcb_info.nb_tcs; i++)
+   printf("\t%4d%%", dcb_info.tc_bws[i]);
+   printf("\n  RXQ base :  ");
+   for (i = 0; i < dcb_info.nb_tcs; i

[dpdk-dev] [PATCH 0/3] export hotplug capability

2015-10-29 Thread David Marchand
This little patchset makes it possible for an application to know if a port
supports hotplug.


-- 
David Marchand

Maxime Leroy (3):
  ethdev: rework value return by rte_eth_dev_is_detachable
  ethdev: export rte_eth_dev_is_detachable function
  ethdev: prevent segfaults in rte_eth_dev_is_detachable

 lib/librte_ether/rte_ethdev.c  | 15 +--
 lib/librte_ether/rte_ethdev.h  | 12 
 lib/librte_ether/rte_ether_version.map |  7 +++
 3 files changed, 28 insertions(+), 6 deletions(-)

-- 
1.9.1



[dpdk-dev] [PATCH 1/3] ethdev: rework value return by rte_eth_dev_is_detachable

2015-10-29 Thread David Marchand
From: Maxime Leroy 

The rte_eth_dev_is_detachable return 0 when the device is detachable.
It not, it returns a negative value or 1.

This patch modifies this function to return 1 when the device is detachable
and 0 when is not.

Signed-off-by: Maxime Leroy 
Signed-off-by: David Marchand 
---
 lib/librte_ether/rte_ethdev.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index f593f6e..396667c 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -507,7 +507,7 @@ rte_eth_dev_is_detachable(uint8_t port_id)

if (!rte_eth_dev_is_valid_port(port_id)) {
PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id);
-   return -EINVAL;
+   return 0;
}

if (rte_eth_devices[port_id].dev_type == RTE_ETH_DEV_PCI) {
@@ -518,12 +518,12 @@ rte_eth_dev_is_detachable(uint8_t port_id)
break;
case RTE_KDRV_VFIO:
default:
-   return -ENOTSUP;
+   return 0;
}
}

drv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags;
-   return !(drv_flags & RTE_PCI_DRV_DETACHABLE);
+   return drv_flags & RTE_PCI_DRV_DETACHABLE;
 }

 /* attach the new physical device, then store port_id of the device */
@@ -571,7 +571,7 @@ rte_eth_dev_detach_pdev(uint8_t port_id, struct 
rte_pci_addr *addr)
goto err;

/* check whether the driver supports detach feature, or not */
-   if (rte_eth_dev_is_detachable(port_id))
+   if (!rte_eth_dev_is_detachable(port_id))
goto err;

/* get pci address by port id */
@@ -648,7 +648,7 @@ rte_eth_dev_detach_vdev(uint8_t port_id, char *vdevname)
goto err;

/* check whether the driver supports detach feature, or not */
-   if (rte_eth_dev_is_detachable(port_id))
+   if (!rte_eth_dev_is_detachable(port_id))
goto err;

/* get device name by port id */
-- 
1.9.1



[dpdk-dev] [PATCH 2/3] ethdev: export rte_eth_dev_is_detachable function

2015-10-29 Thread David Marchand
From: Maxime Leroy 

It can be useful for application to know if a port can be detached or not.

Signed-off-by: Maxime Leroy 
Signed-off-by: David Marchand 
---
 lib/librte_ether/rte_ethdev.c  |  2 +-
 lib/librte_ether/rte_ethdev.h  | 12 
 lib/librte_ether/rte_ether_version.map |  7 +++
 3 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 396667c..7fa5717 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -500,7 +500,7 @@ rte_eth_dev_get_name_by_port(uint8_t port_id, char *name)
return 0;
 }

-static int
+int
 rte_eth_dev_is_detachable(uint8_t port_id)
 {
uint32_t drv_flags;
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 8a8c82b..160edd4 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -1558,6 +1558,18 @@ int rte_eth_dev_attach(const char *devargs, uint8_t 
*port_id);
  */
 int rte_eth_dev_detach(uint8_t port_id, char *devname);

+/**
+ * Check if an Ethernet device specified by port identifer is detachable.
+ *
+ * @param port_id
+ *   The port identifier of the device to check if is detachable
+ *
+ * @return
+ *  1 if device is detachable, else 0
+ */
+int
+rte_eth_dev_is_detachable(uint8_t port_id);
+
 struct eth_driver;
 /**
  * @internal
diff --git a/lib/librte_ether/rte_ether_version.map 
b/lib/librte_ether/rte_ether_version.map
index 8345a6c..7f872c2 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -127,3 +127,10 @@ DPDK_2.1 {
rte_eth_timesync_read_tx_timestamp;

 } DPDK_2.0;
+
+DPDK_2.2 {
+   global:
+
+   rte_eth_dev_is_detachable;
+
+} DPDK_2.1;
-- 
1.9.1



[dpdk-dev] [PATCH 3/3] ethdev: prevent segfaults in rte_eth_dev_is_detachable

2015-10-29 Thread David Marchand
From: Maxime Leroy 

Some drivers like virtual ones don't specify any driver pointer in the
structure rte_eth_dev.

To prevent segfault, we should check if this pointer is NULL before
dereferencing it.

Signed-off-by: Maxime Leroy 
Signed-off-by: David Marchand 
---
 lib/librte_ether/rte_ethdev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 7fa5717..750e4b5 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -522,6 +522,9 @@ rte_eth_dev_is_detachable(uint8_t port_id)
}
}

+   if (rte_eth_devices[port_id].driver == NULL)
+   return 0;
+
drv_flags = rte_eth_devices[port_id].driver->pci_drv.drv_flags;
return drv_flags & RTE_PCI_DRV_DETACHABLE;
 }
-- 
1.9.1



[dpdk-dev] [PATCH v3 0/8] interrupt mode for e1000

2015-10-29 Thread Yong Liu
v3 changes:
add in release note

v2 changes:
describe interrupt mode work with uio and vfio+msi
replace attribuite __unused__ with __rte_unused

This patch set will enable interrup for physical and emulated e1000 device.
Rx queue interrupt will work with uio driver or vfio driver with msi mode.
l3fwd-power will disable interrupt immediately when wake-up for that e1000 not
support interrupt auto clear.
LSC and rxq interrupt will be seperated for e1000 can only support one
interrupt cause in the same time.

The patch set is developed based on one previous patch set
"[PATCH v1 00/11] interrupt mode for i40e"
http://www.dpdk.org/ml/archives/dev/2015-September/023903.html

Marvin Liu (7):
  e1000: add rx interrupt support
  e1000: separate lsc and rxq interrupt disable function
  e1000: add ethdev rxq enable and disable function
  e1000: add rxq interrupt handler
  e1000: check lsc and rxq not enable in the same time
  e1000: lsc interrupt setup function only enable itself
  l3fwd-power: disable interrupt when wake up from sleep

 drivers/net/e1000/em_ethdev.c | 181 +-
 examples/l3fwd-power/main.c   |   1 +
 2 files changed, 163 insertions(+), 19 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH] virtio: fix size of mac_addrs array in virtio ports

2015-10-29 Thread Yuanhan Liu
On Thu, Oct 29, 2015 at 09:46:15AM +0100, David Marchand wrote:
> From: Ivan Boule 
> 
> Make the virtio PMD allocate the array of unicast MAC addresses with
> the maximum of entries (VIRTIO_MAX_MAC_ADDRS) that it exports.
> 
> Signed-off-by: Ivan Boule 
> Signed-off-by: David Marchand 
> ---
>  drivers/net/virtio/virtio_ethdev.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_ethdev.c 
> b/drivers/net/virtio/virtio_ethdev.c
> index 12fcc23..79a97c3 100644
> --- a/drivers/net/virtio/virtio_ethdev.c
> +++ b/drivers/net/virtio/virtio_ethdev.c
> @@ -1175,11 +1175,11 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
>   }
>  
>   /* Allocate memory for storing MAC addresses */
> - eth_dev->data->mac_addrs = rte_zmalloc("virtio", ETHER_ADDR_LEN, 0);
> + eth_dev->data->mac_addrs = rte_zmalloc("virtio", VIRTIO_MAX_MAC_ADDRS * 
> ETHER_ADDR_LEN, 0);

Looks good to me, except that you should try to limit it to 80 chars.

--yliu

>   if (eth_dev->data->mac_addrs == NULL) {
>   PMD_INIT_LOG(ERR,
>   "Failed to allocate %d bytes needed to store MAC 
> addresses",
> - ETHER_ADDR_LEN);
> + VIRTIO_MAX_MAC_ADDRS * ETHER_ADDR_LEN);
>   return -ENOMEM;
>   }
>  
> -- 
> 1.9.1


[dpdk-dev] [PATCH v4 00/16] Vector Rx/Tx PMD implementation for fm10k

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

v4:
 - Clear HW/SW ring content after allocating mbuf failed.

v3:
 - Add a blank line after variable definition.
 - Do floor alignment for passing in argument nb_pkts to avoid memory 
overwritten.
 - Only scan max of 32 desc in scatter Rx function to avoid memory overwritten.

v2:
 - Fix a typo issue.
 - Fix an improper prefetch in vector RX function, in which prefetches
   un-initialized mbuf.
 - Remove limitation on number of desc pointer in vector RX function.
 - Re-organize some comments.
 - Add a new patch to fix a crash issue in vector RX func.
 - Add a new patch to update release notes.

v1:
This patch set includes Vector Rx/Tx functions to receive/transmit packets
for fm10k devices. It also contains logic to do sanity check for proper
RX/TX function selections.

Chen Jing D(Mark) (16):
  fm10k: add new vPMD file
  fm10k: add vPMD pre-condition check for each RX queue
  fm10k: Add a new func to initialize all parameters
  fm10k: add func to re-allocate mbuf for RX ring
  fm10k: add 2 functions to parse pkt_type and offload flag
  fm10k: add Vector RX function
  fm10k: add func to do Vector RX condition check
  fm10k: add Vector RX scatter function
  fm10k: add function to decide best RX function
  fm10k: add func to release mbuf in case Vector RX applied
  fm10k: add Vector TX function
  fm10k: use func pointer to reset TX queue and mbuf release
  fm10k: introduce 2 funcs to reset TX queue and mbuf release
  fm10k: Add function to decide best TX func
  fm10k: fix a crash issue in vector RX func
  doc: release notes update for fm10k Vector PMD

 doc/guides/rel_notes/release_2_2.rst |5 +
 drivers/net/fm10k/Makefile   |1 +
 drivers/net/fm10k/fm10k.h|   45 ++-
 drivers/net/fm10k/fm10k_ethdev.c |  169 ++-
 drivers/net/fm10k/fm10k_rxtx_vec.c   |  847 ++
 5 files changed, 1039 insertions(+), 28 deletions(-)
 create mode 100644 drivers/net/fm10k/fm10k_rxtx_vec.c

-- 
1.7.7.6



[dpdk-dev] [PATCH v4 01/16] fm10k: add new vPMD file

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Add new file fm10k_rxtx_vec.c and add it into compiling.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/Makefile |1 +
 drivers/net/fm10k/fm10k_rxtx_vec.c |   45 
 2 files changed, 46 insertions(+), 0 deletions(-)
 create mode 100644 drivers/net/fm10k/fm10k_rxtx_vec.c

diff --git a/drivers/net/fm10k/Makefile b/drivers/net/fm10k/Makefile
index a4a8f56..06ebf83 100644
--- a/drivers/net/fm10k/Makefile
+++ b/drivers/net/fm10k/Makefile
@@ -93,6 +93,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_common.c
 SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_mbx.c
 SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_vf.c
 SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_api.c
+SRCS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += fm10k_rxtx_vec.c

 # this lib depends upon:
 DEPDIRS-$(CONFIG_RTE_LIBRTE_FM10K_PMD) += lib/librte_eal lib/librte_ether
diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
new file mode 100644
index 000..69174d9
--- /dev/null
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -0,0 +1,45 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2013-2015 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 "fm10k.h"
+#include "base/fm10k_type.h"
+
+#include 
+
+#ifndef __INTEL_COMPILER
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif
-- 
1.7.7.6



[dpdk-dev] [PATCH v4 02/16] fm10k: add vPMD pre-condition check for each RX queue

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Add condition check in rx_queue_setup func. If number of RX desc
can't satisfy vPMD requirement, record it into a variable. Or
call fm10k_rxq_vec_setup to initialize Vector RX.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k.h  |   11 ---
 drivers/net/fm10k/fm10k_ethdev.c   |   11 +++
 drivers/net/fm10k/fm10k_rxtx_vec.c |   21 +
 3 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index c089882..362a2d0 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -135,6 +135,8 @@ struct fm10k_dev_info {
/* Protect the mailbox to avoid race condition */
rte_spinlock_tmbx_lock;
struct fm10k_macvlan_filter_infomacvlan;
+   /* Flag to indicate if RX vector conditions satisfied */
+   bool rx_vec_allowed;
 };

 /*
@@ -165,9 +167,10 @@ struct fm10k_rx_queue {
struct rte_mempool *mp;
struct rte_mbuf **sw_ring;
volatile union fm10k_rx_desc *hw_ring;
-   struct rte_mbuf *pkt_first_seg; /**< First segment of current packet. */
-   struct rte_mbuf *pkt_last_seg;  /**< Last segment of current packet. */
+   struct rte_mbuf *pkt_first_seg; /* First segment of current packet. */
+   struct rte_mbuf *pkt_last_seg;  /* Last segment of current packet. */
uint64_t hw_ring_phys_addr;
+   uint64_t mbuf_initializer; /* value to init mbufs */
uint16_t next_dd;
uint16_t next_alloc;
uint16_t next_trigger;
@@ -177,7 +180,7 @@ struct fm10k_rx_queue {
uint16_t queue_id;
uint8_t port_id;
uint8_t drop_en;
-   uint8_t rx_deferred_start; /**< don't start this queue in dev start. */
+   uint8_t rx_deferred_start; /* don't start this queue in dev start. */
 };

 /*
@@ -313,4 +316,6 @@ uint16_t fm10k_recv_scattered_pkts(void *rx_queue,

 uint16_t fm10k_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);
+
+int fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq);
 #endif
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index a69c990..3c7784e 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -1251,6 +1251,7 @@ fm10k_rx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_id,
const struct rte_eth_rxconf *conf, struct rte_mempool *mp)
 {
struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct fm10k_dev_info *dev_info = FM10K_DEV_PRIVATE_TO_INFO(dev);
struct fm10k_rx_queue *q;
const struct rte_memzone *mz;

@@ -1333,6 +1334,16 @@ fm10k_rx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_id,
q->hw_ring_phys_addr = mz->phys_addr;
 #endif

+   /* Check if number of descs satisfied Vector requirement */
+   if (!rte_is_power_of_2(nb_desc)) {
+   PMD_INIT_LOG(DEBUG, "queue[%d] doesn't meet Vector Rx "
+   "preconditions - canceling the feature for "
+   "the whole port[%d]",
+q->queue_id, q->port_id);
+   dev_info->rx_vec_allowed = false;
+   } else
+   fm10k_rxq_vec_setup(q);
+
dev->data->rx_queues[queue_id] = q;
return 0;
 }
diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 69174d9..34b677b 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -43,3 +43,24 @@
 #ifndef __INTEL_COMPILER
 #pragma GCC diagnostic ignored "-Wcast-qual"
 #endif
+
+int __attribute__((cold))
+fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq)
+{
+   uintptr_t p;
+   struct rte_mbuf mb_def = { .buf_addr = 0 }; /* zeroed mbuf */
+
+   mb_def.nb_segs = 1;
+   /* data_off will be ajusted after new mbuf allocated for 512-byte
+* alignment.
+*/
+   mb_def.data_off = RTE_PKTMBUF_HEADROOM;
+   mb_def.port = rxq->port_id;
+   rte_mbuf_refcnt_set(&mb_def, 1);
+
+   /* prevent compiler reordering: rearm_data covers previous fields */
+   rte_compiler_barrier();
+   p = (uintptr_t)&mb_def.rearm_data;
+   rxq->mbuf_initializer = *(uint64_t *)p;
+   return 0;
+}
-- 
1.7.7.6



[dpdk-dev] [PATCH v4 03/16] fm10k: Add a new func to initialize all parameters

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Add new function fm10k_params_init to initialize all fm10k related
variables.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k_ethdev.c |   35 +++
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 3c7784e..363ef98 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -2066,6 +2066,27 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
.rss_hash_conf_get  = fm10k_rss_hash_conf_get,
 };

+static void
+fm10k_params_init(struct rte_eth_dev *dev)
+{
+   struct fm10k_hw *hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct fm10k_dev_info *info = FM10K_DEV_PRIVATE_TO_INFO(dev);
+
+   /* Inialize bus info. Normally we would call fm10k_get_bus_info(), but
+* there is no way to get link status without reading BAR4.  Until this
+* works, assume we have maximum bandwidth.
+* @todo - fix bus info
+*/
+   hw->bus_caps.speed = fm10k_bus_speed_8000;
+   hw->bus_caps.width = fm10k_bus_width_pcie_x8;
+   hw->bus_caps.payload = fm10k_bus_payload_512;
+   hw->bus.speed = fm10k_bus_speed_8000;
+   hw->bus.width = fm10k_bus_width_pcie_x8;
+   hw->bus.payload = fm10k_bus_payload_256;
+
+   info->rx_vec_allowed = true;
+}
+
 static int
 eth_fm10k_dev_init(struct rte_eth_dev *dev)
 {
@@ -2112,18 +2133,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
return -EIO;
}

-   /*
-* Inialize bus info. Normally we would call fm10k_get_bus_info(), but
-* there is no way to get link status without reading BAR4.  Until this
-* works, assume we have maximum bandwidth.
-* @todo - fix bus info
-*/
-   hw->bus_caps.speed = fm10k_bus_speed_8000;
-   hw->bus_caps.width = fm10k_bus_width_pcie_x8;
-   hw->bus_caps.payload = fm10k_bus_payload_512;
-   hw->bus.speed = fm10k_bus_speed_8000;
-   hw->bus.width = fm10k_bus_width_pcie_x8;
-   hw->bus.payload = fm10k_bus_payload_256;
+   /* Initialize parameters */
+   fm10k_params_init(dev);

/* Initialize the hw */
diag = fm10k_init_hw(hw);
-- 
1.7.7.6



[dpdk-dev] [PATCH v4 04/16] fm10k: add func to re-allocate mbuf for RX ring

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Add function fm10k_rxq_rearm to re-allocate mbuf for used desc
in RX HW ring.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k.h  |   11 
 drivers/net/fm10k/fm10k_ethdev.c   |3 +
 drivers/net/fm10k/fm10k_rxtx_vec.c |   98 
 3 files changed, 112 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index 362a2d0..5513644 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -123,6 +123,12 @@
 #define FM10K_VFTA_BIT(vlan_id)(1 << ((vlan_id) & 0x1F))
 #define FM10K_VFTA_IDX(vlan_id)((vlan_id) >> 5)

+#define RTE_FM10K_RXQ_REARM_THRESH  32
+#define RTE_FM10K_VPMD_TX_BURST 32
+#define RTE_FM10K_MAX_RX_BURST  RTE_FM10K_RXQ_REARM_THRESH
+#define RTE_FM10K_TX_MAX_FREE_BUF_SZ64
+#define RTE_FM10K_DESCS_PER_LOOP4
+
 struct fm10k_macvlan_filter_info {
uint16_t vlan_num;   /* Total VLAN number */
uint16_t mac_num;/* Total mac number */
@@ -171,6 +177,8 @@ struct fm10k_rx_queue {
struct rte_mbuf *pkt_last_seg;  /* Last segment of current packet. */
uint64_t hw_ring_phys_addr;
uint64_t mbuf_initializer; /* value to init mbufs */
+   /** need to alloc dummy mbuf, for wraparound when scanning hw ring */
+   struct rte_mbuf fake_mbuf;
uint16_t next_dd;
uint16_t next_alloc;
uint16_t next_trigger;
@@ -178,6 +186,9 @@ struct fm10k_rx_queue {
volatile uint32_t *tail_ptr;
uint16_t nb_desc;
uint16_t queue_id;
+   /* Below 2 fields only valid in case vPMD is applied. */
+   uint16_t rxrearm_nb; /* number of remaining to be re-armed */
+   uint16_t rxrearm_start;  /* the idx we start the re-arming from */
uint8_t port_id;
uint8_t drop_en;
uint8_t rx_deferred_start; /* don't start this queue in dev start. */
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 363ef98..44c3d34 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -121,6 +121,9 @@ rx_queue_reset(struct fm10k_rx_queue *q)
q->next_alloc = 0;
q->next_trigger = q->alloc_thresh - 1;
FM10K_PCI_REG_WRITE(q->tail_ptr, q->nb_desc - 1);
+   q->rxrearm_start = 0;
+   q->rxrearm_nb = 0;
+
return 0;
 }

diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 34b677b..6c21f15 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -64,3 +64,101 @@ fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq)
rxq->mbuf_initializer = *(uint64_t *)p;
return 0;
 }
+
+static inline void
+fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
+{
+   int i;
+   uint16_t rx_id;
+   volatile union fm10k_rx_desc *rxdp;
+   struct rte_mbuf **mb_alloc = &rxq->sw_ring[rxq->rxrearm_start];
+   struct rte_mbuf *mb0, *mb1;
+   __m128i head_off = _mm_set_epi64x(
+   RTE_PKTMBUF_HEADROOM + FM10K_RX_DATABUF_ALIGN - 1,
+   RTE_PKTMBUF_HEADROOM + FM10K_RX_DATABUF_ALIGN - 1);
+   __m128i dma_addr0, dma_addr1;
+   /* Rx buffer need to be aligned with 512 byte */
+   const __m128i hba_msk = _mm_set_epi64x(0,
+   UINT64_MAX - FM10K_RX_DATABUF_ALIGN + 1);
+
+   rxdp = rxq->hw_ring + rxq->rxrearm_start;
+
+   /* Pull 'n' more MBUFs into the software ring */
+   if (rte_mempool_get_bulk(rxq->mp,
+(void *)mb_alloc,
+RTE_FM10K_RXQ_REARM_THRESH) < 0) {
+   dma_addr0 = _mm_setzero_si128();
+   /* Clean up all the HW/SW ring content */
+   for (i = 0; i < RTE_FM10K_RXQ_REARM_THRESH; i++) {
+   mb_alloc[i] = &rxq->fake_mbuf;
+   _mm_store_si128((__m128i *)&rxdp[i].q,
+   dma_addr0);
+   }
+
+   rte_eth_devices[rxq->port_id].data->rx_mbuf_alloc_failed +=
+   RTE_FM10K_RXQ_REARM_THRESH;
+   return;
+   }
+
+   /* Initialize the mbufs in vector, process 2 mbufs in one loop */
+   for (i = 0; i < RTE_FM10K_RXQ_REARM_THRESH; i += 2, mb_alloc += 2) {
+   __m128i vaddr0, vaddr1;
+   uintptr_t p0, p1;
+
+   mb0 = mb_alloc[0];
+   mb1 = mb_alloc[1];
+
+   /* Flush mbuf with pkt template.
+* Data to be rearmed is 6 bytes long.
+* Though, RX will overwrite ol_flags that are coming next
+* anyway. So overwrite whole 8 bytes with one load:
+* 6 bytes of rearm_data plus first 2 bytes of ol_flags.
+*/
+   p0 = (uintptr_t)&mb0->rearm_data;
+   *(uint64_t *)p0 = rxq->mbuf_initializer;
+   p1 

[dpdk-dev] [PATCH v4 05/16] fm10k: add 2 functions to parse pkt_type and offload flag

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Add 2 functions, in which using SSE instructions to parse RX desc
to get pkt_type and ol_flags in mbuf.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k_rxtx_vec.c |  127 
 1 files changed, 127 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 6c21f15..88c9536 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -44,6 +44,133 @@
 #pragma GCC diagnostic ignored "-Wcast-qual"
 #endif

+/* Handling the offload flags (olflags) field takes computation
+ * time when receiving packets. Therefore we provide a flag to disable
+ * the processing of the olflags field when they are not needed. This
+ * gives improved performance, at the cost of losing the offload info
+ * in the received packet
+ */
+#ifdef RTE_LIBRTE_FM10K_RX_OLFLAGS_ENABLE
+
+/* Vlan present flag shift */
+#define VP_SHIFT (2)
+/* L3 type shift */
+#define L3TYPE_SHIFT (4)
+/* L4 type shift */
+#define L4TYPE_SHIFT (7)
+
+static inline void
+fm10k_desc_to_olflags_v(__m128i descs[4], struct rte_mbuf **rx_pkts)
+{
+   __m128i ptype0, ptype1, vtag0, vtag1;
+   union {
+   uint16_t e[4];
+   uint64_t dword;
+   } vol;
+
+   const __m128i pkttype_msk = _mm_set_epi16(
+   0x, 0x, 0x, 0x,
+   PKT_RX_VLAN_PKT, PKT_RX_VLAN_PKT,
+   PKT_RX_VLAN_PKT, PKT_RX_VLAN_PKT);
+
+   /* mask everything except rss type */
+   const __m128i rsstype_msk = _mm_set_epi16(
+   0x, 0x, 0x, 0x,
+   0x000F, 0x000F, 0x000F, 0x000F);
+
+   /* map rss type to rss hash flag */
+   const __m128i rss_flags = _mm_set_epi8(0, 0, 0, 0,
+   0, 0, 0, PKT_RX_RSS_HASH,
+   PKT_RX_RSS_HASH, 0, PKT_RX_RSS_HASH, 0,
+   PKT_RX_RSS_HASH, PKT_RX_RSS_HASH, PKT_RX_RSS_HASH, 0);
+
+   ptype0 = _mm_unpacklo_epi16(descs[0], descs[1]);
+   ptype1 = _mm_unpacklo_epi16(descs[2], descs[3]);
+   vtag0 = _mm_unpackhi_epi16(descs[0], descs[1]);
+   vtag1 = _mm_unpackhi_epi16(descs[2], descs[3]);
+
+   ptype0 = _mm_unpacklo_epi32(ptype0, ptype1);
+   ptype0 = _mm_and_si128(ptype0, rsstype_msk);
+   ptype0 = _mm_shuffle_epi8(rss_flags, ptype0);
+
+   vtag1 = _mm_unpacklo_epi32(vtag0, vtag1);
+   vtag1 = _mm_srli_epi16(vtag1, VP_SHIFT);
+   vtag1 = _mm_and_si128(vtag1, pkttype_msk);
+
+   vtag1 = _mm_or_si128(ptype0, vtag1);
+   vol.dword = _mm_cvtsi128_si64(vtag1);
+
+   rx_pkts[0]->ol_flags = vol.e[0];
+   rx_pkts[1]->ol_flags = vol.e[1];
+   rx_pkts[2]->ol_flags = vol.e[2];
+   rx_pkts[3]->ol_flags = vol.e[3];
+}
+
+static inline void
+fm10k_desc_to_pktype_v(__m128i descs[4], struct rte_mbuf **rx_pkts)
+{
+   __m128i l3l4type0, l3l4type1, l3type, l4type;
+   union {
+   uint16_t e[4];
+   uint64_t dword;
+   } vol;
+
+   /* L3 pkt type mask  Bit4 to Bit6 */
+   const __m128i l3type_msk = _mm_set_epi16(
+   0x, 0x, 0x, 0x,
+   0x0070, 0x0070, 0x0070, 0x0070);
+
+   /* L4 pkt type mask  Bit7 to Bit9 */
+   const __m128i l4type_msk = _mm_set_epi16(
+   0x, 0x, 0x, 0x,
+   0x0380, 0x0380, 0x0380, 0x0380);
+
+   /* convert RRC l3 type to mbuf format */
+   const __m128i l3type_flags = _mm_set_epi8(0, 0, 0, 0, 0, 0, 0, 0,
+   0, 0, 0, RTE_PTYPE_L3_IPV6_EXT,
+   RTE_PTYPE_L3_IPV6, RTE_PTYPE_L3_IPV4_EXT,
+   RTE_PTYPE_L3_IPV4, 0);
+
+   /* Convert RRC l4 type to mbuf format l4type_flags shift-left 8 bits
+* to fill into8 bits length.
+*/
+   const __m128i l4type_flags = _mm_set_epi8(0, 0, 0, 0, 0, 0, 0, 0, 0,
+   RTE_PTYPE_TUNNEL_GENEVE >> 8,
+   RTE_PTYPE_TUNNEL_NVGRE >> 8,
+   RTE_PTYPE_TUNNEL_VXLAN >> 8,
+   RTE_PTYPE_TUNNEL_GRE >> 8,
+   RTE_PTYPE_L4_UDP >> 8,
+   RTE_PTYPE_L4_TCP >> 8,
+   0);
+
+   l3l4type0 = _mm_unpacklo_epi16(descs[0], descs[1]);
+   l3l4type1 = _mm_unpacklo_epi16(descs[2], descs[3]);
+   l3l4type0 = _mm_unpacklo_epi32(l3l4type0, l3l4type1);
+
+   l3type = _mm_and_si128(l3l4type0, l3type_msk);
+   l4type = _mm_and_si128(l3l4type0, l4type_msk);
+
+   l3type = _mm_srli_epi16(l3type, L3TYPE_SHIFT);
+   l4type = _mm_srli_epi16(l4type, L4TYPE_SHIFT);
+
+   l3type = _mm_shuffle_epi8(l3type_flags, l3type);
+   /* l4type_flags shift-left for 8 bits, need shift-right back */
+   l4type = _mm_shuffle_epi8(l4type_flags, l4type);
+
+   l4type = _mm_slli_epi16(l4type,

[dpdk-dev] [PATCH v4 06/16] fm10k: add Vector RX function

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Add func fm10k_recv_raw_pkts_vec to parse raw packets, in which
includes possible chained packets.
Add func fm10k_recv_pkts_vec to receive single mbuf packet.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k.h  |1 +
 drivers/net/fm10k/fm10k_rxtx_vec.c |  201 
 2 files changed, 202 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index 5513644..96b30a7 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -329,4 +329,5 @@ uint16_t fm10k_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts,
uint16_t nb_pkts);

 int fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq);
+uint16_t fm10k_recv_pkts_vec(void *, struct rte_mbuf **, uint16_t);
 #endif
diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 88c9536..8c535f0 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -289,3 +289,204 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
/* Update the tail pointer on the NIC */
FM10K_PCI_REG_WRITE(rxq->tail_ptr, rx_id);
 }
+
+static inline uint16_t
+fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
+   uint16_t nb_pkts, uint8_t *split_packet)
+{
+   volatile union fm10k_rx_desc *rxdp;
+   struct rte_mbuf **mbufp;
+   uint16_t nb_pkts_recd;
+   int pos;
+   struct fm10k_rx_queue *rxq = rx_queue;
+   uint64_t var;
+   __m128i shuf_msk;
+   __m128i dd_check, eop_check;
+   uint16_t next_dd;
+
+   next_dd = rxq->next_dd;
+
+   /* Just the act of getting into the function from the application is
+* going to cost about 7 cycles
+*/
+   rxdp = rxq->hw_ring + next_dd;
+
+   _mm_prefetch((const void *)rxdp, _MM_HINT_T0);
+
+   /* See if we need to rearm the RX queue - gives the prefetch a bit
+* of time to act
+*/
+   if (rxq->rxrearm_nb > RTE_FM10K_RXQ_REARM_THRESH)
+   fm10k_rxq_rearm(rxq);
+
+   /* Before we start moving massive data around, check to see if
+* there is actually a packet available
+*/
+   if (!(rxdp->d.staterr & FM10K_RXD_STATUS_DD))
+   return 0;
+
+   /* Vecotr RX will process 4 packets at a time, strip the unaligned
+* tails in case it's not multiple of 4.
+*/
+   nb_pkts = RTE_ALIGN_FLOOR(nb_pkts, RTE_FM10K_DESCS_PER_LOOP);
+
+   /* 4 packets DD mask */
+   dd_check = _mm_set_epi64x(0x00010001LL, 0x00010001LL);
+
+   /* 4 packets EOP mask */
+   eop_check = _mm_set_epi64x(0x00020002LL, 0x00020002LL);
+
+   /* mask to shuffle from desc. to mbuf */
+   shuf_msk = _mm_set_epi8(
+   7, 6, 5, 4,  /* octet 4~7, 32bits rss */
+   15, 14,  /* octet 14~15, low 16 bits vlan_macip */
+   13, 12,  /* octet 12~13, 16 bits data_len */
+   0xFF, 0xFF,  /* skip high 16 bits pkt_len, zero out */
+   13, 12,  /* octet 12~13, low 16 bits pkt_len */
+   0xFF, 0xFF,  /* skip high 16 bits pkt_type */
+   0xFF, 0xFF   /* Skip pkt_type field in shuffle operation */
+   );
+
+   /* Cache is empty -> need to scan the buffer rings, but first move
+* the next 'n' mbufs into the cache
+*/
+   mbufp = &rxq->sw_ring[next_dd];
+
+   /* A. load 4 packet in one loop
+* [A*. mask out 4 unused dirty field in desc]
+* B. copy 4 mbuf point from swring to rx_pkts
+* C. calc the number of DD bits among the 4 packets
+* [C*. extract the end-of-packet bit, if requested]
+* D. fill info. from desc to mbuf
+*/
+   for (pos = 0, nb_pkts_recd = 0; pos < nb_pkts;
+   pos += RTE_FM10K_DESCS_PER_LOOP,
+   rxdp += RTE_FM10K_DESCS_PER_LOOP) {
+   __m128i descs0[RTE_FM10K_DESCS_PER_LOOP];
+   __m128i pkt_mb1, pkt_mb2, pkt_mb3, pkt_mb4;
+   __m128i zero, staterr, sterr_tmp1, sterr_tmp2;
+   __m128i mbp1, mbp2; /* two mbuf pointer in one XMM reg. */
+
+   /* B.1 load 1 mbuf point */
+   mbp1 = _mm_loadu_si128((__m128i *)&mbufp[pos]);
+
+   /* Read desc statuses backwards to avoid race condition */
+   /* A.1 load 4 pkts desc */
+   descs0[3] = _mm_loadu_si128((__m128i *)(rxdp + 3));
+
+   /* B.2 copy 2 mbuf point into rx_pkts  */
+   _mm_storeu_si128((__m128i *)&rx_pkts[pos], mbp1);
+
+   /* B.1 load 1 mbuf point */
+   mbp2 = _mm_loadu_si128((__m128i *)&mbufp[pos+2]);
+
+   descs0[2] = _mm_loadu_si128((__m128i *)(rxdp + 2));
+   /* B.1 load 2 mbuf point */
+   descs0[1] = _mm_loadu_si128((__m128i *)(rxdp + 1));
+   descs0[0] = _mm_loadu_s

[dpdk-dev] [PATCH v4 07/16] fm10k: add func to do Vector RX condition check

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Add func fm10k_rx_vec_condition_check to check if Vector RX
func can be applied.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k.h  |1 +
 drivers/net/fm10k/fm10k_rxtx_vec.c |   31 +++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index 96b30a7..6c1c698 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -329,5 +329,6 @@ uint16_t fm10k_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts,
uint16_t nb_pkts);

 int fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq);
+int fm10k_rx_vec_condition_check(struct rte_eth_dev *);
 uint16_t fm10k_recv_pkts_vec(void *, struct rte_mbuf **, uint16_t);
 #endif
diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 8c535f0..4ecb471 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -172,6 +172,37 @@ fm10k_desc_to_pktype_v(__m128i descs[4], struct rte_mbuf 
**rx_pkts)
 #endif

 int __attribute__((cold))
+fm10k_rx_vec_condition_check(struct rte_eth_dev *dev)
+{
+#ifndef RTE_LIBRTE_IEEE1588
+   struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+   struct rte_fdir_conf *fconf = &dev->data->dev_conf.fdir_conf;
+
+#ifndef RTE_FM10K_RX_OLFLAGS_ENABLE
+   /* whithout rx ol_flags, no VP flag report */
+   if (rxmode->hw_vlan_extend != 0)
+   return -1;
+#endif
+
+   /* no fdir support */
+   if (fconf->mode != RTE_FDIR_MODE_NONE)
+   return -1;
+
+   /* - no csum error report support
+* - no header split support
+*/
+   if (rxmode->hw_ip_checksum == 1 ||
+   rxmode->header_split == 1)
+   return -1;
+
+   return 0;
+#else
+   RTE_SET_USED(dev);
+   return -1;
+#endif
+}
+
+int __attribute__((cold))
 fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq)
 {
uintptr_t p;
-- 
1.7.7.6



[dpdk-dev] [PATCH v4 08/16] fm10k: add Vector RX scatter function

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Add func fm10k_recv_scattered_pkts_vec to receive chained packets
with SSE instructions.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k.h  |2 +
 drivers/net/fm10k/fm10k_rxtx_vec.c |   88 
 2 files changed, 90 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index 6c1c698..8dba27b 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -331,4 +331,6 @@ uint16_t fm10k_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts,
 int fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq);
 int fm10k_rx_vec_condition_check(struct rte_eth_dev *);
 uint16_t fm10k_recv_pkts_vec(void *, struct rte_mbuf **, uint16_t);
+uint16_t fm10k_recv_scattered_pkts_vec(void *, struct rte_mbuf **,
+   uint16_t);
 #endif
diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 4ecb471..2d1dfa3 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -521,3 +521,91 @@ fm10k_recv_pkts_vec(void *rx_queue, struct rte_mbuf 
**rx_pkts,
 {
return fm10k_recv_raw_pkts_vec(rx_queue, rx_pkts, nb_pkts, NULL);
 }
+
+static inline uint16_t
+fm10k_reassemble_packets(struct fm10k_rx_queue *rxq,
+   struct rte_mbuf **rx_bufs,
+   uint16_t nb_bufs, uint8_t *split_flags)
+{
+   struct rte_mbuf *pkts[RTE_FM10K_MAX_RX_BURST]; /*finished pkts*/
+   struct rte_mbuf *start = rxq->pkt_first_seg;
+   struct rte_mbuf *end =  rxq->pkt_last_seg;
+   unsigned pkt_idx, buf_idx;
+
+
+   for (buf_idx = 0, pkt_idx = 0; buf_idx < nb_bufs; buf_idx++) {
+   if (end != NULL) {
+   /* processing a split packet */
+   end->next = rx_bufs[buf_idx];
+   start->nb_segs++;
+   start->pkt_len += rx_bufs[buf_idx]->data_len;
+   end = end->next;
+
+   if (!split_flags[buf_idx]) {
+   /* it's the last packet of the set */
+   start->hash = end->hash;
+   start->ol_flags = end->ol_flags;
+   pkts[pkt_idx++] = start;
+   start = end = NULL;
+   }
+   } else {
+   /* not processing a split packet */
+   if (!split_flags[buf_idx]) {
+   /* not a split packet, save and skip */
+   pkts[pkt_idx++] = rx_bufs[buf_idx];
+   continue;
+   }
+   end = start = rx_bufs[buf_idx];
+   }
+   }
+
+   /* save the partial packet for next time */
+   rxq->pkt_first_seg = start;
+   rxq->pkt_last_seg = end;
+   memcpy(rx_bufs, pkts, pkt_idx * (sizeof(*pkts)));
+   return pkt_idx;
+}
+
+/*
+ * vPMD receive routine that reassembles scattered packets
+ *
+ * Notice:
+ * - don't support ol_flags for rss and csum err
+ * - nb_pkts > RTE_FM10K_MAX_RX_BURST, only scan RTE_FM10K_MAX_RX_BURST
+ *   numbers of DD bit
+ */
+uint16_t
+fm10k_recv_scattered_pkts_vec(void *rx_queue,
+   struct rte_mbuf **rx_pkts,
+   uint16_t nb_pkts)
+{
+   struct fm10k_rx_queue *rxq = rx_queue;
+   uint8_t split_flags[RTE_FM10K_MAX_RX_BURST] = {0};
+   unsigned i = 0;
+
+   /* Split_flags only can support max of RTE_FM10K_MAX_RX_BURST */
+   nb_pkts = RTE_MIN(nb_pkts, RTE_FM10K_MAX_RX_BURST);
+   /* get some new buffers */
+   uint16_t nb_bufs = fm10k_recv_raw_pkts_vec(rxq, rx_pkts, nb_pkts,
+   split_flags);
+   if (nb_bufs == 0)
+   return 0;
+
+   /* happy day case, full burst + no packets to be joined */
+   const uint64_t *split_fl64 = (uint64_t *)split_flags;
+   if (rxq->pkt_first_seg == NULL &&
+   split_fl64[0] == 0 && split_fl64[1] == 0 &&
+   split_fl64[2] == 0 && split_fl64[3] == 0)
+   return nb_bufs;
+
+   /* reassemble any packets that need reassembly*/
+   if (rxq->pkt_first_seg == NULL) {
+   /* find the first split flag, and only reassemble then*/
+   while (i < nb_bufs && !split_flags[i])
+   i++;
+   if (i == nb_bufs)
+   return nb_bufs;
+   }
+   return i + fm10k_reassemble_packets(rxq, &rx_pkts[i], nb_bufs - i,
+   &split_flags[i]);
+}
-- 
1.7.7.6



[dpdk-dev] [PATCH v4 09/16] fm10k: add function to decide best RX function

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Add func fm10k_set_rx_function to decide best RX func in
fm10k_dev_rx_init

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k.h|1 +
 drivers/net/fm10k/fm10k_ethdev.c |   36 
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index 8dba27b..5666af6 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -189,6 +189,7 @@ struct fm10k_rx_queue {
/* Below 2 fields only valid in case vPMD is applied. */
uint16_t rxrearm_nb; /* number of remaining to be re-armed */
uint16_t rxrearm_start;  /* the idx we start the re-arming from */
+   uint16_t rx_using_sse; /* indicates that vector RX is in use */
uint8_t port_id;
uint8_t drop_en;
uint8_t rx_deferred_start; /* don't start this queue in dev start. */
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 44c3d34..4690a0c 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -67,6 +67,7 @@ static void
 fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev);
 static void fm10k_tx_queue_release(void *queue);
 static void fm10k_rx_queue_release(void *queue);
+static void fm10k_set_rx_function(struct rte_eth_dev *dev);

 static void
 fm10k_mbx_initlock(struct fm10k_hw *hw)
@@ -462,7 +463,6 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev)
dev->data->dev_conf.rxmode.enable_scatter) {
uint32_t reg;
dev->data->scattered_rx = 1;
-   dev->rx_pkt_burst = fm10k_recv_scattered_pkts;
reg = FM10K_READ_REG(hw, FM10K_SRRCTL(i));
reg |= FM10K_SRRCTL_BUFFER_CHAINING_EN;
FM10K_WRITE_REG(hw, FM10K_SRRCTL(i), reg);
@@ -478,6 +478,9 @@ fm10k_dev_rx_init(struct rte_eth_dev *dev)

/* Configure RSS if applicable */
fm10k_dev_mq_rx_configure(dev);
+
+   /* Decide the best RX function */
+   fm10k_set_rx_function(dev);
return 0;
 }

@@ -2069,6 +2072,34 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
.rss_hash_conf_get  = fm10k_rss_hash_conf_get,
 };

+static void __attribute__((cold))
+fm10k_set_rx_function(struct rte_eth_dev *dev)
+{
+   struct fm10k_dev_info *dev_info = FM10K_DEV_PRIVATE_TO_INFO(dev);
+   uint16_t i, rx_using_sse;
+
+   /* In order to allow Vector Rx there are a few configuration
+* conditions to be met.
+*/
+   if (!fm10k_rx_vec_condition_check(dev) && dev_info->rx_vec_allowed) {
+   if (dev->data->scattered_rx)
+   dev->rx_pkt_burst = fm10k_recv_scattered_pkts_vec;
+   else
+   dev->rx_pkt_burst = fm10k_recv_pkts_vec;
+   } else if (dev->data->scattered_rx)
+   dev->rx_pkt_burst = fm10k_recv_scattered_pkts;
+
+   rx_using_sse =
+   (dev->rx_pkt_burst == fm10k_recv_scattered_pkts_vec ||
+   dev->rx_pkt_burst == fm10k_recv_pkts_vec);
+
+   for (i = 0; i < dev->data->nb_rx_queues; i++) {
+   struct fm10k_rx_queue *rxq = dev->data->rx_queues[i];
+   rxq->rx_using_sse = rx_using_sse;
+   }
+
+}
+
 static void
 fm10k_params_init(struct rte_eth_dev *dev)
 {
@@ -2103,9 +2134,6 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
dev->rx_pkt_burst = &fm10k_recv_pkts;
dev->tx_pkt_burst = &fm10k_xmit_pkts;

-   if (dev->data->scattered_rx)
-   dev->rx_pkt_burst = &fm10k_recv_scattered_pkts;
-
/* only initialize in the primary process */
if (rte_eal_process_type() != RTE_PROC_PRIMARY)
return 0;
-- 
1.7.7.6



[dpdk-dev] [PATCH v4 10/16] fm10k: add func to release mbuf in case Vector RX applied

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Since Vector RX use different variables to trace RX HW ring, it
leads to need different func to release mbuf properly.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k.h  |1 +
 drivers/net/fm10k/fm10k_ethdev.c   |6 ++
 drivers/net/fm10k/fm10k_rxtx_vec.c |   18 ++
 3 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index 5666af6..d17b2fb 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -331,6 +331,7 @@ uint16_t fm10k_xmit_pkts(void *tx_queue, struct rte_mbuf 
**tx_pkts,

 int fm10k_rxq_vec_setup(struct fm10k_rx_queue *rxq);
 int fm10k_rx_vec_condition_check(struct rte_eth_dev *);
+void fm10k_rx_queue_release_mbufs_vec(struct fm10k_rx_queue *rxq);
 uint16_t fm10k_recv_pkts_vec(void *, struct rte_mbuf **, uint16_t);
 uint16_t fm10k_recv_scattered_pkts_vec(void *, struct rte_mbuf **,
uint16_t);
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 4690a0c..a46a349 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -143,6 +143,12 @@ rx_queue_clean(struct fm10k_rx_queue *q)
for (i = 0; i < q->nb_desc; ++i)
q->hw_ring[i] = zero;

+   /* vPMD driver has a different way of releasing mbufs. */
+   if (q->rx_using_sse) {
+   fm10k_rx_queue_release_mbufs_vec(q);
+   return;
+   }
+
/* free software buffers */
for (i = 0; i < q->nb_desc; ++i) {
if (q->sw_ring[i]) {
diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 2d1dfa3..0869aa3 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -321,6 +321,24 @@ fm10k_rxq_rearm(struct fm10k_rx_queue *rxq)
FM10K_PCI_REG_WRITE(rxq->tail_ptr, rx_id);
 }

+void __attribute__((cold))
+fm10k_rx_queue_release_mbufs_vec(struct fm10k_rx_queue *rxq)
+{
+   const unsigned mask = rxq->nb_desc - 1;
+   unsigned i;
+
+   if (rxq->sw_ring == NULL || rxq->rxrearm_nb >= rxq->nb_desc)
+   return;
+
+   /* free all mbufs that are valid in the ring */
+   for (i = rxq->next_dd; i != rxq->rxrearm_start; i = (i + 1) & mask)
+   rte_pktmbuf_free_seg(rxq->sw_ring[i]);
+   rxq->rxrearm_nb = rxq->nb_desc;
+
+   /* set all entries to NULL */
+   memset(rxq->sw_ring, 0, sizeof(rxq->sw_ring[0]) * rxq->nb_desc);
+}
+
 static inline uint16_t
 fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts, uint8_t *split_packet)
-- 
1.7.7.6



[dpdk-dev] [PATCH v4 12/16] fm10k: use func pointer to reset TX queue and mbuf release

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Vector TX use different way to manage TX queue, it's necessary
to use different functions to reset TX queue and release mbuf
in TX queue. So, introduce 2 function pointers to do such ops.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k.h|9 +
 drivers/net/fm10k/fm10k_ethdev.c |   21 -
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index 5525b72..bfb71da 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -206,11 +206,14 @@ struct fifo {
uint16_t *endp;
 };

+struct fm10k_txq_ops;
+
 struct fm10k_tx_queue {
struct rte_mbuf **sw_ring;
struct fm10k_tx_desc *hw_ring;
uint64_t hw_ring_phys_addr;
struct fifo rs_tracker;
+   const struct fm10k_txq_ops *ops; /* txq ops */
uint16_t last_free;
uint16_t next_free;
uint16_t nb_free;
@@ -227,6 +230,11 @@ struct fm10k_tx_queue {
uint16_t queue_id;
 };

+struct fm10k_txq_ops {
+   void (*release_mbufs)(struct fm10k_tx_queue *txq);
+   void (*reset)(struct fm10k_tx_queue *txq);
+};
+
 #define MBUF_DMA_ADDR(mb) \
((uint64_t) ((mb)->buf_physaddr + (mb)->data_off))

@@ -340,4 +348,5 @@ uint16_t fm10k_recv_scattered_pkts_vec(void *, struct 
rte_mbuf **,
uint16_t);
 uint16_t fm10k_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
uint16_t nb_pkts);
+void fm10k_txq_vec_setup(struct fm10k_tx_queue *txq);
 #endif
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index a46a349..88bd887 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -292,6 +292,11 @@ tx_queue_disable(struct fm10k_hw *hw, uint16_t qnum)
return 0;
 }

+static const struct fm10k_txq_ops def_txq_ops = {
+   .release_mbufs = tx_queue_free,
+   .reset = tx_queue_reset,
+};
+
 static int
 fm10k_dev_configure(struct rte_eth_dev *dev)
 {
@@ -571,7 +576,8 @@ fm10k_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t 
tx_queue_id)
PMD_INIT_FUNC_TRACE();

if (tx_queue_id < dev->data->nb_tx_queues) {
-   tx_queue_reset(dev->data->tx_queues[tx_queue_id]);
+   struct fm10k_tx_queue *q = dev->data->tx_queues[tx_queue_id];
+   q->ops->reset(q);

/* reset head and tail pointers */
FM10K_WRITE_REG(hw, FM10K_TDH(tx_queue_id), 0);
@@ -837,8 +843,10 @@ fm10k_dev_queue_release(struct rte_eth_dev *dev)
PMD_INIT_FUNC_TRACE();

if (dev->data->tx_queues) {
-   for (i = 0; i < dev->data->nb_tx_queues; i++)
-   fm10k_tx_queue_release(dev->data->tx_queues[i]);
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   struct fm10k_tx_queue *txq = dev->data->tx_queues[i];
+   txq->ops->release_mbufs(txq);
+   }
}

if (dev->data->rx_queues) {
@@ -1454,7 +1462,8 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_id,
 * different socket than was previously used.
 */
if (dev->data->tx_queues[queue_id] != NULL) {
-   tx_queue_free(dev->data->tx_queues[queue_id]);
+   struct fm10k_tx_queue *txq = dev->data->tx_queues[queue_id];
+   txq->ops->release_mbufs(txq);
dev->data->tx_queues[queue_id] = NULL;
}

@@ -1470,6 +1479,7 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_id,
q->nb_desc = nb_desc;
q->port_id = dev->data->port_id;
q->queue_id = queue_id;
+   q->ops = &def_txq_ops;
q->tail_ptr = (volatile uint32_t *)
&((uint32_t *)hw->hw_addr)[FM10K_TDT(queue_id)];
if (handle_txconf(q, conf))
@@ -1528,9 +1538,10 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_id,
 static void
 fm10k_tx_queue_release(void *queue)
 {
+   struct fm10k_tx_queue *q = queue;
PMD_INIT_FUNC_TRACE();

-   tx_queue_free(queue);
+   q->ops->release_mbufs(q);
 }

 static int
-- 
1.7.7.6



[dpdk-dev] [PATCH v4 11/16] fm10k: add Vector TX function

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Add Vector TX func fm10k_xmit_pkts_vec to transmit packets.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k.h  |5 +
 drivers/net/fm10k/fm10k_rxtx_vec.c |  150 
 2 files changed, 155 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index d17b2fb..5525b72 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -217,6 +217,9 @@ struct fm10k_tx_queue {
uint16_t nb_used;
uint16_t free_thresh;
uint16_t rs_thresh;
+   /* Below 2 fields only valid in case vPMD is applied. */
+   uint16_t next_rs; /* Next pos to set RS flag */
+   uint16_t next_dd; /* Next pos to check DD flag */
volatile uint32_t *tail_ptr;
uint16_t nb_desc;
uint8_t port_id;
@@ -335,4 +338,6 @@ void fm10k_rx_queue_release_mbufs_vec(struct fm10k_rx_queue 
*rxq);
 uint16_t fm10k_recv_pkts_vec(void *, struct rte_mbuf **, uint16_t);
 uint16_t fm10k_recv_scattered_pkts_vec(void *, struct rte_mbuf **,
uint16_t);
+uint16_t fm10k_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
+   uint16_t nb_pkts);
 #endif
diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 0869aa3..37418bf 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -627,3 +627,153 @@ fm10k_recv_scattered_pkts_vec(void *rx_queue,
return i + fm10k_reassemble_packets(rxq, &rx_pkts[i], nb_bufs - i,
&split_flags[i]);
 }
+
+static inline void
+vtx1(volatile struct fm10k_tx_desc *txdp,
+   struct rte_mbuf *pkt, uint64_t flags)
+{
+   __m128i descriptor = _mm_set_epi64x(flags << 56 |
+   pkt->vlan_tci << 16 | pkt->data_len,
+   MBUF_DMA_ADDR(pkt));
+   _mm_store_si128((__m128i *)txdp, descriptor);
+}
+
+static inline void
+vtx(volatile struct fm10k_tx_desc *txdp,
+   struct rte_mbuf **pkt, uint16_t nb_pkts,  uint64_t flags)
+{
+   int i;
+
+   for (i = 0; i < nb_pkts; ++i, ++txdp, ++pkt)
+   vtx1(txdp, *pkt, flags);
+}
+
+static inline int __attribute__((always_inline))
+fm10k_tx_free_bufs(struct fm10k_tx_queue *txq)
+{
+   struct rte_mbuf **txep;
+   uint8_t flags;
+   uint32_t n;
+   uint32_t i;
+   int nb_free = 0;
+   struct rte_mbuf *m, *free[RTE_FM10K_TX_MAX_FREE_BUF_SZ];
+
+   /* check DD bit on threshold descriptor */
+   flags = txq->hw_ring[txq->next_dd].flags;
+   if (!(flags & FM10K_TXD_FLAG_DONE))
+   return 0;
+
+   n = txq->rs_thresh;
+
+   /* First buffer to free from S/W ring is at index
+* next_dd - (rs_thresh-1)
+*/
+   txep = &txq->sw_ring[txq->next_dd - (n - 1)];
+   m = __rte_pktmbuf_prefree_seg(txep[0]);
+   if (likely(m != NULL)) {
+   free[0] = m;
+   nb_free = 1;
+   for (i = 1; i < n; i++) {
+   m = __rte_pktmbuf_prefree_seg(txep[i]);
+   if (likely(m != NULL)) {
+   if (likely(m->pool == free[0]->pool))
+   free[nb_free++] = m;
+   else {
+   rte_mempool_put_bulk(free[0]->pool,
+   (void *)free, nb_free);
+   free[0] = m;
+   nb_free = 1;
+   }
+   }
+   }
+   rte_mempool_put_bulk(free[0]->pool, (void **)free, nb_free);
+   } else {
+   for (i = 1; i < n; i++) {
+   m = __rte_pktmbuf_prefree_seg(txep[i]);
+   if (m != NULL)
+   rte_mempool_put(m->pool, m);
+   }
+   }
+
+   /* buffers were freed, update counters */
+   txq->nb_free = (uint16_t)(txq->nb_free + txq->rs_thresh);
+   txq->next_dd = (uint16_t)(txq->next_dd + txq->rs_thresh);
+   if (txq->next_dd >= txq->nb_desc)
+   txq->next_dd = (uint16_t)(txq->rs_thresh - 1);
+
+   return txq->rs_thresh;
+}
+
+static inline void __attribute__((always_inline))
+tx_backlog_entry(struct rte_mbuf **txep,
+struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
+{
+   int i;
+
+   for (i = 0; i < (int)nb_pkts; ++i)
+   txep[i] = tx_pkts[i];
+}
+
+uint16_t
+fm10k_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts,
+   uint16_t nb_pkts)
+{
+   struct fm10k_tx_queue *txq = (struct fm10k_tx_queue *)tx_queue;
+   volatile struct fm10k_tx_desc *txdp;
+   struct rte_mbuf **txep;
+   uint16_t n, nb_commit, tx_id;
+   uint64_t flags = FM10K_TXD_FLAG_LAST;
+   uint64_t rs = FM10K_TXD_FLAG_RS | FM10

[dpdk-dev] [PATCH v4 14/16] fm10k: Add function to decide best TX func

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Add func fm10k_set_tx_function to decide the best TX func in
fm10k_dev_tx_init.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k.h|1 +
 drivers/net/fm10k/fm10k_ethdev.c |   38 --
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index bfb71da..8e2c6a4 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -224,6 +224,7 @@ struct fm10k_tx_queue {
uint16_t next_rs; /* Next pos to set RS flag */
uint16_t next_dd; /* Next pos to check DD flag */
volatile uint32_t *tail_ptr;
+   uint32_t txq_flags; /* Holds flags for this TXq */
uint16_t nb_desc;
uint8_t port_id;
uint8_t tx_deferred_start; /** < don't start this queue in dev start. */
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 88bd887..469bd85 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -53,6 +53,9 @@
 #define CHARS_PER_UINT32 (sizeof(uint32_t))
 #define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1)

+#define FM10K_SIMPLE_TX_FLAG ((uint32_t)ETH_TXQ_FLAGS_NOMULTSEGS | \
+   ETH_TXQ_FLAGS_NOOFFLOADS)
+
 static void fm10k_close_mbx_service(struct fm10k_hw *hw);
 static void fm10k_dev_promiscuous_enable(struct rte_eth_dev *dev);
 static void fm10k_dev_promiscuous_disable(struct rte_eth_dev *dev);
@@ -68,6 +71,7 @@ fm10k_MACVLAN_remove_all(struct rte_eth_dev *dev);
 static void fm10k_tx_queue_release(void *queue);
 static void fm10k_rx_queue_release(void *queue);
 static void fm10k_set_rx_function(struct rte_eth_dev *dev);
+static void fm10k_set_tx_function(struct rte_eth_dev *dev);

 static void
 fm10k_mbx_initlock(struct fm10k_hw *hw)
@@ -414,6 +418,10 @@ fm10k_dev_tx_init(struct rte_eth_dev *dev)
base_addr >> (CHAR_BIT * sizeof(uint32_t)));
FM10K_WRITE_REG(hw, FM10K_TDLEN(i), size);
}
+
+   /* set up vector or scalar TX function as appropriate */
+   fm10k_set_tx_function(dev);
+
return 0;
 }

@@ -980,8 +988,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
},
.tx_free_thresh = FM10K_TX_FREE_THRESH_DEFAULT(0),
.tx_rs_thresh = FM10K_TX_RS_THRESH_DEFAULT(0),
-   .txq_flags = ETH_TXQ_FLAGS_NOMULTSEGS |
-   ETH_TXQ_FLAGS_NOOFFLOADS,
+   .txq_flags = FM10K_SIMPLE_TX_FLAG,
};

 }
@@ -1479,6 +1486,7 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_id,
q->nb_desc = nb_desc;
q->port_id = dev->data->port_id;
q->queue_id = queue_id;
+   q->txq_flags = conf->txq_flags;
q->ops = &def_txq_ops;
q->tail_ptr = (volatile uint32_t *)
&((uint32_t *)hw->hw_addr)[FM10K_TDT(queue_id)];
@@ -2090,6 +2098,32 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
 };

 static void __attribute__((cold))
+fm10k_set_tx_function(struct rte_eth_dev *dev)
+{
+   struct fm10k_tx_queue *txq;
+   int i;
+   int use_sse = 1;
+
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   if ((txq->txq_flags & FM10K_SIMPLE_TX_FLAG) != \
+   FM10K_SIMPLE_TX_FLAG) {
+   use_sse = 0;
+   break;
+   }
+   }
+
+   if (use_sse) {
+   for (i = 0; i < dev->data->nb_tx_queues; i++) {
+   txq = dev->data->tx_queues[i];
+   fm10k_txq_vec_setup(txq);
+   }
+   dev->tx_pkt_burst = fm10k_xmit_pkts_vec;
+   } else
+   dev->tx_pkt_burst = fm10k_xmit_pkts;
+}
+
+static void __attribute__((cold))
 fm10k_set_rx_function(struct rte_eth_dev *dev)
 {
struct fm10k_dev_info *dev_info = FM10K_DEV_PRIVATE_TO_INFO(dev);
-- 
1.7.7.6



[dpdk-dev] [PATCH v4 13/16] fm10k: introduce 2 funcs to reset TX queue and mbuf release

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Add 2 funcs to reset TX queue and mbuf release when Vector TX
applied.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k_rxtx_vec.c |   68 
 1 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c 
b/drivers/net/fm10k/fm10k_rxtx_vec.c
index 37418bf..e572715 100644
--- a/drivers/net/fm10k/fm10k_rxtx_vec.c
+++ b/drivers/net/fm10k/fm10k_rxtx_vec.c
@@ -44,6 +44,11 @@
 #pragma GCC diagnostic ignored "-Wcast-qual"
 #endif

+static void
+fm10k_tx_queue_release_mbufs_vec(struct fm10k_tx_queue *txq);
+static void
+fm10k_reset_tx_queue(struct fm10k_tx_queue *txq);
+
 /* Handling the offload flags (olflags) field takes computation
  * time when receiving packets. Therefore we provide a flag to disable
  * the processing of the olflags field when they are not needed. This
@@ -628,6 +633,17 @@ fm10k_recv_scattered_pkts_vec(void *rx_queue,
&split_flags[i]);
 }

+static const struct fm10k_txq_ops vec_txq_ops = {
+   .release_mbufs = fm10k_tx_queue_release_mbufs_vec,
+   .reset = fm10k_reset_tx_queue,
+};
+
+void __attribute__((cold))
+fm10k_txq_vec_setup(struct fm10k_tx_queue *txq)
+{
+   txq->ops = &vec_txq_ops;
+}
+
 static inline void
 vtx1(volatile struct fm10k_tx_desc *txdp,
struct rte_mbuf *pkt, uint64_t flags)
@@ -777,3 +793,55 @@ fm10k_xmit_pkts_vec(void *tx_queue, struct rte_mbuf 
**tx_pkts,

return nb_pkts;
 }
+
+static void __attribute__((cold))
+fm10k_tx_queue_release_mbufs_vec(struct fm10k_tx_queue *txq)
+{
+   unsigned i;
+   const uint16_t max_desc = (uint16_t)(txq->nb_desc - 1);
+
+   if (txq->sw_ring == NULL || txq->nb_free == max_desc)
+   return;
+
+   /* release the used mbufs in sw_ring */
+   for (i = txq->next_dd - (txq->rs_thresh - 1);
+i != txq->next_free;
+i = (i + 1) & max_desc)
+   rte_pktmbuf_free_seg(txq->sw_ring[i]);
+
+   txq->nb_free = max_desc;
+
+   /* reset tx_entry */
+   for (i = 0; i < txq->nb_desc; i++)
+   txq->sw_ring[i] = NULL;
+
+   rte_free(txq->sw_ring);
+   txq->sw_ring = NULL;
+}
+
+static void __attribute__((cold))
+fm10k_reset_tx_queue(struct fm10k_tx_queue *txq)
+{
+   static const struct fm10k_tx_desc zeroed_desc = {0};
+   struct rte_mbuf **txe = txq->sw_ring;
+   uint16_t i;
+
+   /* Zero out HW ring memory */
+   for (i = 0; i < txq->nb_desc; i++)
+   txq->hw_ring[i] = zeroed_desc;
+
+   /* Initialize SW ring entries */
+   for (i = 0; i < txq->nb_desc; i++)
+   txe[i] = NULL;
+
+   txq->next_dd = (uint16_t)(txq->rs_thresh - 1);
+   txq->next_rs = (uint16_t)(txq->rs_thresh - 1);
+
+   txq->next_free = 0;
+   txq->nb_used = 0;
+   /* Always allow 1 descriptor to be un-allocated to avoid
+* a H/W race condition
+*/
+   txq->nb_free = (uint16_t)(txq->nb_desc - 1);
+   FM10K_PCI_REG_WRITE(txq->tail_ptr, 0);
+}
-- 
1.7.7.6



[dpdk-dev] [PATCH v4 15/16] fm10k: fix a crash issue in vector RX func

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Vector RX function will process 4 packets at a time. When the RX
ring wrapps to the tail and the left descriptor size is not multiple
of 4, SW will overwrite memory that not belongs to it and cause crash.
The fix will allocate additional 4 HW/SW spaces at the tail to avoid
overwrite.

Signed-off-by: Chen Jing D(Mark) 
---
 drivers/net/fm10k/fm10k.h|4 +++-
 drivers/net/fm10k/fm10k_ethdev.c |   19 +--
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
index 8e2c6a4..82a548f 100644
--- a/drivers/net/fm10k/fm10k.h
+++ b/drivers/net/fm10k/fm10k.h
@@ -177,7 +177,7 @@ struct fm10k_rx_queue {
struct rte_mbuf *pkt_last_seg;  /* Last segment of current packet. */
uint64_t hw_ring_phys_addr;
uint64_t mbuf_initializer; /* value to init mbufs */
-   /** need to alloc dummy mbuf, for wraparound when scanning hw ring */
+   /* need to alloc dummy mbuf, for wraparound when scanning hw ring */
struct rte_mbuf fake_mbuf;
uint16_t next_dd;
uint16_t next_alloc;
@@ -185,6 +185,8 @@ struct fm10k_rx_queue {
uint16_t alloc_thresh;
volatile uint32_t *tail_ptr;
uint16_t nb_desc;
+   /* Number of faked desc added at the tail for Vector RX function */
+   uint16_t nb_fake_desc;
uint16_t queue_id;
/* Below 2 fields only valid in case vPMD is applied. */
uint16_t rxrearm_nb; /* number of remaining to be re-armed */
diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c
index 469bd85..705b311 100644
--- a/drivers/net/fm10k/fm10k_ethdev.c
+++ b/drivers/net/fm10k/fm10k_ethdev.c
@@ -102,6 +102,7 @@ fm10k_mbx_unlock(struct fm10k_hw *hw)
 static inline int
 rx_queue_reset(struct fm10k_rx_queue *q)
 {
+   static const union fm10k_rx_desc zero = {{0} };
uint64_t dma_addr;
int i, diag;
PMD_INIT_FUNC_TRACE();
@@ -122,6 +123,15 @@ rx_queue_reset(struct fm10k_rx_queue *q)
q->hw_ring[i].q.hdr_addr = dma_addr;
}

+   /* initialize extra software ring entries. Space for these extra
+* entries is always allocated.
+*/
+   memset(&q->fake_mbuf, 0x0, sizeof(q->fake_mbuf));
+   for (i = 0; i < q->nb_fake_desc; ++i) {
+   q->sw_ring[q->nb_desc + i] = &q->fake_mbuf;
+   q->hw_ring[q->nb_desc + i] = zero;
+   }
+
q->next_dd = 0;
q->next_alloc = 0;
q->next_trigger = q->alloc_thresh - 1;
@@ -147,6 +157,10 @@ rx_queue_clean(struct fm10k_rx_queue *q)
for (i = 0; i < q->nb_desc; ++i)
q->hw_ring[i] = zero;

+   /* zero faked descriptors */
+   for (i = 0; i < q->nb_fake_desc; ++i)
+   q->hw_ring[q->nb_desc + i] = zero;
+
/* vPMD driver has a different way of releasing mbufs. */
if (q->rx_using_sse) {
fm10k_rx_queue_release_mbufs_vec(q);
@@ -1323,6 +1337,7 @@ fm10k_rx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_id,
/* setup queue */
q->mp = mp;
q->nb_desc = nb_desc;
+   q->nb_fake_desc = FM10K_MULT_RX_DESC;
q->port_id = dev->data->port_id;
q->queue_id = queue_id;
q->tail_ptr = (volatile uint32_t *)
@@ -1332,8 +1347,8 @@ fm10k_rx_queue_setup(struct rte_eth_dev *dev, uint16_t 
queue_id,

/* allocate memory for the software ring */
q->sw_ring = rte_zmalloc_socket("fm10k sw ring",
-   nb_desc * sizeof(struct rte_mbuf *),
-   RTE_CACHE_LINE_SIZE, socket_id);
+   (nb_desc + q->nb_fake_desc) * sizeof(struct rte_mbuf *),
+   RTE_CACHE_LINE_SIZE, socket_id);
if (q->sw_ring == NULL) {
PMD_INIT_LOG(ERR, "Cannot allocate software ring");
rte_free(q);
-- 
1.7.7.6



[dpdk-dev] [PATCH v2] virtio: fix size of mac_addrs array in virtio ports

2015-10-29 Thread David Marchand
From: Ivan Boule 

Make the virtio PMD allocate the array of unicast MAC addresses with
the maximum of entries (VIRTIO_MAX_MAC_ADDRS) that it exports.

Signed-off-by: Ivan Boule 
Signed-off-by: David Marchand 
---
Changes since v1:
* fix checkpatch warning (thanks Yuanhan)

 drivers/net/virtio/virtio_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 12fcc23..636b182 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1163,6 +1163,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
struct virtio_net_config *config;
struct virtio_net_config local_config;
struct rte_pci_device *pci_dev;
+   const size_t mac_array_size = VIRTIO_MAX_MAC_ADDRS * ETHER_ADDR_LEN;

RTE_BUILD_BUG_ON(RTE_PKTMBUF_HEADROOM < sizeof(struct virtio_net_hdr));

@@ -1175,11 +1176,11 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
}

/* Allocate memory for storing MAC addresses */
-   eth_dev->data->mac_addrs = rte_zmalloc("virtio", ETHER_ADDR_LEN, 0);
+   eth_dev->data->mac_addrs = rte_zmalloc("virtio", mac_array_size, 0);
if (eth_dev->data->mac_addrs == NULL) {
PMD_INIT_LOG(ERR,
"Failed to allocate %d bytes needed to store MAC 
addresses",
-   ETHER_ADDR_LEN);
+   mac_array_size);
return -ENOMEM;
}

-- 
1.9.1



[dpdk-dev] [PATCH v4 16/16] doc: release notes update for fm10k Vector PMD

2015-10-29 Thread Chen Jing D(Mark)
From: "Chen Jing D(Mark)" 

Update 2.2 release notes, add descriptions for Vector PMD implementation
in fm10k driver.

Signed-off-by: Chen Jing D(Mark) 
---
 doc/guides/rel_notes/release_2_2.rst |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/doc/guides/rel_notes/release_2_2.rst 
b/doc/guides/rel_notes/release_2_2.rst
index 9a70dae..44a3f74 100644
--- a/doc/guides/rel_notes/release_2_2.rst
+++ b/doc/guides/rel_notes/release_2_2.rst
@@ -39,6 +39,11 @@ Drivers

   Fixed issue with libvirt ``virsh destroy`` not killing the VM.

+* **fm10k:  Add Vector Rx/Tx implementation.**
+
+  This patch set includes Vector Rx/Tx functions to receive/transmit packets
+  for fm10k devices. It also contains logic to do sanity check for proper
+  RX/TX function selections.

 Libraries
 ~
-- 
1.7.7.6



[dpdk-dev] [PATCH v3 0/8] interrupt mode for e1000

2015-10-29 Thread Yong Liu
This patch set will enable interrup for physical and emulated e1000 device.
Rx queue interrupt will work with uio driver or vfio driver with msi mode.
l3fwd-power will disable interrupt immediately when wake-up for that e1000 not
support interrupt auto clear.
LSC and rxq interrupt will be seperated for e1000 can only support one
interrupt cause in the same time.

The patch set is developed based on one previous patch set
"[PATCH v1 00/11] interrupt mode for i40e"
http://www.dpdk.org/ml/archives/dev/2015-September/023903.html

v3 changes:
add in release note

v2 changes:
describe interrupt mode work with uio and vfio+msi
replace attribuite __unused__ with __rte_unused

Marvin Liu (8):
  e1000: add rx interrupt support
  e1000: separate lsc and rxq interrupt disable function
  e1000: add ethdev rxq enable and disable function
  e1000: add rxq interrupt handler
  e1000: check lsc and rxq not enable in the same time
  e1000: lsc interrupt setup function only enable itself
  l3fwd-power: disable interrupt when wake up from sleep
  doc: release note update for e1000 intr mode

 doc/guides/rel_notes/release_2_2.rst |   1 +
 drivers/net/e1000/em_ethdev.c| 181 +++
 examples/l3fwd-power/main.c  |   1 +
 3 files changed, 164 insertions(+), 19 deletions(-)

-- 
1.9.3



[dpdk-dev] [PATCH v3 2/8] e1000: separate lsc and rxq interrupt disable function

2015-10-29 Thread Yong Liu
Separate lsc and rxq interrupt for they have different interrupt handlers.

Signed-off-by: Marvin Liu 

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 3be8269..39f330a 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -108,11 +108,12 @@ static void em_vlan_hw_strip_disable(struct rte_eth_dev 
*dev);
 static void eth_em_vlan_filter_set(struct rte_eth_dev *dev,
uint16_t vlan_id, int on);
 */
+static void em_lsc_intr_disable(struct e1000_hw *hw);
 static void em_rxq_intr_enable(struct e1000_hw *hw);
+static void em_rxq_intr_disable(struct e1000_hw *hw);
 static int eth_em_led_on(struct rte_eth_dev *dev);
 static int eth_em_led_off(struct rte_eth_dev *dev);

-static void em_intr_disable(struct e1000_hw *hw);
 static int em_get_rx_buffer_size(struct e1000_hw *hw);
 static void eth_em_rar_set(struct rte_eth_dev *dev, struct ether_addr 
*mac_addr,
uint32_t index, uint32_t pool);
@@ -640,7 +641,9 @@ eth_em_stop(struct rte_eth_dev *dev)
struct rte_eth_link link;
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

-   em_intr_disable(hw);
+   em_rxq_intr_disable(hw);
+   em_lsc_intr_disable(hw);
+
e1000_reset_hw(hw);
if (hw->mac.type >= e1000_82544)
E1000_WRITE_REG(hw, E1000_WUC, 0);
@@ -1254,13 +1257,7 @@ eth_em_vlan_offload_set(struct rte_eth_dev *dev, int 
mask)
}
 }

-static void
-em_intr_disable(struct e1000_hw *hw)
-{
-   E1000_WRITE_REG(hw, E1000_IMC, ~0);
-}
-
-/**
+/*
  * It enables the interrupt mask and then enable the interrupt.
  *
  * @param dev
@@ -1304,6 +1301,35 @@ eth_em_rxq_interrupt_setup(struct rte_eth_dev *dev)
 }

 /*
+ * It disabled lsc interrupt.
+ * @param hw
+ * Pointer to struct e1000_hw
+ *
+ * @return
+ */
+static void
+em_lsc_intr_disable(struct e1000_hw *hw)
+{
+   E1000_WRITE_REG(hw, E1000_IMC, E1000_IMS_LSC);
+   E1000_WRITE_FLUSH(hw);
+}
+
+/*
+ * It disabled receive packet interrupt.
+ * @param hw
+ * Pointer to struct e1000_hw
+ *
+ * @return
+ */
+static void
+em_rxq_intr_disable(struct e1000_hw *hw)
+{
+   E1000_READ_REG(hw, E1000_ICR);
+   E1000_WRITE_REG(hw, E1000_IMC, E1000_IMS_RXT0);
+   E1000_WRITE_FLUSH(hw);
+}
+
+/*
  * It enable receive packet interrupt.
  * @param hw
  * Pointer to struct e1000_hw
-- 
1.9.3



[dpdk-dev] [PATCH v3 3/8] e1000: add ethdev rxq enable and disable function

2015-10-29 Thread Yong Liu
Implement rxq interrupt related functions in eth_dev_ops structure.

Signed-off-by: Marvin Liu 

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 39f330a..6dc2534 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -108,9 +108,13 @@ static void em_vlan_hw_strip_disable(struct rte_eth_dev 
*dev);
 static void eth_em_vlan_filter_set(struct rte_eth_dev *dev,
uint16_t vlan_id, int on);
 */
+
+static int eth_em_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t 
queue_id);
+static int eth_em_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t 
queue_id);
 static void em_lsc_intr_disable(struct e1000_hw *hw);
 static void em_rxq_intr_enable(struct e1000_hw *hw);
 static void em_rxq_intr_disable(struct e1000_hw *hw);
+
 static int eth_em_led_on(struct rte_eth_dev *dev);
 static int eth_em_led_off(struct rte_eth_dev *dev);

@@ -162,6 +166,8 @@ static const struct eth_dev_ops eth_em_ops = {
.rx_descriptor_done   = eth_em_rx_descriptor_done,
.tx_queue_setup   = eth_em_tx_queue_setup,
.tx_queue_release = eth_em_tx_queue_release,
+   .rx_queue_intr_enable = eth_em_rx_queue_intr_enable,
+   .rx_queue_intr_disable = eth_em_rx_queue_intr_disable,
.dev_led_on   = eth_em_led_on,
.dev_led_off  = eth_em_led_off,
.flow_ctrl_get= eth_em_flow_ctrl_get,
@@ -890,6 +896,27 @@ eth_em_stats_reset(struct rte_eth_dev *dev)
memset(hw_stats, 0, sizeof(*hw_stats));
 }

+static int
+eth_em_rx_queue_intr_enable(struct rte_eth_dev *dev, __rte_unused uint16_t 
queue_id)
+{
+   struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   em_rxq_intr_enable(hw);
+   rte_intr_enable(&(dev->pci_dev->intr_handle));
+
+   return 0;
+}
+
+static int
+eth_em_rx_queue_intr_disable(struct rte_eth_dev *dev, __rte_unused uint16_t 
queue_id)
+{
+   struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   em_rxq_intr_disable(hw);
+
+   return 0;
+}
+
 static uint32_t
 em_get_max_pktlen(const struct e1000_hw *hw)
 {
-- 
1.9.3



[dpdk-dev] [PATCH v3 6/8] e1000: lsc interrupt setup function only enable itself

2015-10-29 Thread Yong Liu
Only mask lsc interrupt bit when setup device interrupt.

Signed-off-by: Marvin Liu 

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index b1e0c3c..d2d017c 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -1343,11 +1343,14 @@ eth_em_vlan_offload_set(struct rte_eth_dev *dev, int 
mask)
 static int
 eth_em_interrupt_setup(struct rte_eth_dev *dev)
 {
+   uint32_t regval;
struct e1000_hw *hw =
E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);

-   E1000_WRITE_REG(hw, E1000_IMS, E1000_ICR_LSC);
-   rte_intr_enable(&(dev->pci_dev->intr_handle));
+   /* clear interrupt */
+   E1000_READ_REG(hw, E1000_ICR);
+   regval = E1000_READ_REG(hw, E1000_IMS);
+   E1000_WRITE_REG(hw, E1000_IMS, regval | E1000_ICR_LSC);
return (0);
 }

-- 
1.9.3



[dpdk-dev] [PATCH v3 1/8] e1000: add rx interrupt support

2015-10-29 Thread Yong Liu
Enable rx interrupt support on e1000 physical and emulated device.

Signed-off-by: Marvin Liu 

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 912f5dd..3be8269 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -81,6 +81,7 @@ static int eth_em_flow_ctrl_get(struct rte_eth_dev *dev,
 static int eth_em_flow_ctrl_set(struct rte_eth_dev *dev,
struct rte_eth_fc_conf *fc_conf);
 static int eth_em_interrupt_setup(struct rte_eth_dev *dev);
+static int eth_em_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int eth_em_interrupt_get_status(struct rte_eth_dev *dev);
 static int eth_em_interrupt_action(struct rte_eth_dev *dev);
 static void eth_em_interrupt_handler(struct rte_intr_handle *handle,
@@ -107,6 +108,7 @@ static void em_vlan_hw_strip_disable(struct rte_eth_dev 
*dev);
 static void eth_em_vlan_filter_set(struct rte_eth_dev *dev,
uint16_t vlan_id, int on);
 */
+static void em_rxq_intr_enable(struct e1000_hw *hw);
 static int eth_em_led_on(struct rte_eth_dev *dev);
 static int eth_em_led_off(struct rte_eth_dev *dev);

@@ -608,6 +610,9 @@ eth_em_start(struct rte_eth_dev *dev)
return ret;
}
}
+   /* check if rxq interrupt is enabled */
+   if (dev->data->dev_conf.intr_conf.rxq != 0)
+   eth_em_rxq_interrupt_setup(dev);

adapter->stopped = 0;

@@ -1277,6 +1282,42 @@ eth_em_interrupt_setup(struct rte_eth_dev *dev)
 }

 /*
+ * It clears the interrupt causes and enables the interrupt.
+ * It will be called once only during nic initialized.
+ *
+ * @param dev
+ *  Pointer to struct rte_eth_dev.
+ *
+ * @return
+ *  - On success, zero.
+ *  - On failure, a negative value.
+ */
+static int
+eth_em_rxq_interrupt_setup(struct rte_eth_dev *dev)
+{
+   struct e1000_hw *hw =
+   E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+
+   E1000_READ_REG(hw, E1000_ICR);
+   em_rxq_intr_enable(hw);
+   return 0;
+}
+
+/*
+ * It enable receive packet interrupt.
+ * @param hw
+ * Pointer to struct e1000_hw
+ *
+ * @return
+ */
+static void
+em_rxq_intr_enable(struct e1000_hw *hw)
+{
+   E1000_WRITE_REG(hw, E1000_IMS, E1000_IMS_RXT0);
+   E1000_WRITE_FLUSH(hw);
+}
+
+/*
  * It reads ICR and gets interrupt causes, check it and set a bit flag
  * to update link status.
  *
-- 
1.9.3



[dpdk-dev] [PATCH v3 7/8] l3fwd-power: disable interrupt when wake up from sleep

2015-10-29 Thread Yong Liu
Signed-off-by: Marvin Liu 

diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 8bb88ce..9175989 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -798,6 +798,7 @@ sleep_until_rx_interrupt(int num)
port_id = ((uintptr_t)data) >> CHAR_BIT;
queue_id = ((uintptr_t)data) &
RTE_LEN2MASK(CHAR_BIT, uint8_t);
+   rte_eth_dev_rx_intr_disable(port_id, queue_id);
RTE_LOG(INFO, L3FWD_POWER,
"lcore %u is waked up from rx interrupt on"
" port %d queue %d\n",
-- 
1.9.3



[dpdk-dev] [PATCH v3 5/8] e1000: check lsc and rxq not enable in the same time

2015-10-29 Thread Yong Liu
e1000 only support one type of interrupt cause, so remove lsc interrupt
handler if rxq enabled.

Signed-off-by: Marvin Liu 

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index fc3cc1e..b1e0c3c 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -630,14 +630,22 @@ eth_em_start(struct rte_eth_dev *dev)
}
e1000_setup_link(hw);

-   /* check if lsc interrupt feature is enabled */
-   if (dev->data->dev_conf.intr_conf.lsc != 0) {
-   ret = eth_em_interrupt_setup(dev);
-   if (ret) {
-   PMD_INIT_LOG(ERR, "Unable to setup interrupts");
-   em_dev_clear_queues(dev);
-   return ret;
-   }
+   if (rte_intr_allow_others(intr_handle)) {
+   /* check if lsc interrupt is enabled */
+   if (dev->data->dev_conf.intr_conf.lsc != 0)
+   ret = eth_em_interrupt_setup(dev);
+   if (ret) {
+   PMD_INIT_LOG(ERR, "Unable to setup interrupts");
+   em_dev_clear_queues(dev);
+   return ret;
+   }
+   } else {
+   rte_intr_callback_unregister(intr_handle,
+   eth_em_interrupt_handler,
+   (void *)dev);
+   if (dev->data->dev_conf.intr_conf.lsc != 0)
+   PMD_INIT_LOG(INFO, "lsc won't enable because of"
+" no intr multiplex\n");
}
/* check if rxq interrupt is enabled */
if (dev->data->dev_conf.intr_conf.rxq != 0)
@@ -688,6 +696,12 @@ eth_em_stop(struct rte_eth_dev *dev)
memset(&link, 0, sizeof(link));
rte_em_dev_atomic_write_link_status(dev, &link);

+   if (!rte_intr_allow_others(intr_handle))
+   /* resume to the default handler */
+   rte_intr_callback_register(intr_handle,
+  eth_em_interrupt_handler,
+  (void *)dev);
+
/* Clean datapath event and queue/vec mapping */
rte_intr_efd_disable(intr_handle);
if (intr_handle->intr_vec != NULL) {
-- 
1.9.3



[dpdk-dev] [PATCH v3 4/8] e1000: add rxq interrupt handler

2015-10-29 Thread Yong Liu
When datapath rxq interupt is enabled, enable related device rxq.
Remove the interrupt handler after device stopped.

Signed-off-by: Marvin Liu 

diff --git a/drivers/net/e1000/em_ethdev.c b/drivers/net/e1000/em_ethdev.c
index 6dc2534..fc3cc1e 100644
--- a/drivers/net/e1000/em_ethdev.c
+++ b/drivers/net/e1000/em_ethdev.c
@@ -501,7 +501,9 @@ eth_em_start(struct rte_eth_dev *dev)
E1000_DEV_PRIVATE(dev->data->dev_private);
struct e1000_hw *hw =
E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;
int ret, mask;
+   uint32_t intr_vector = 0;

PMD_INIT_FUNC_TRACE();

@@ -537,6 +539,26 @@ eth_em_start(struct rte_eth_dev *dev)
/* Configure for OS presence */
em_init_manageability(hw);

+   if (dev->data->dev_conf.intr_conf.rxq != 0) {
+   intr_vector = dev->data->nb_rx_queues;
+   if (rte_intr_efd_enable(intr_handle, intr_vector))
+   return -1;
+   }
+
+   if (rte_intr_dp_is_en(intr_handle)) {
+   intr_handle->intr_vec =
+   rte_zmalloc("intr_vec",
+   dev->data->nb_rx_queues * sizeof(int), 
0);
+   if (intr_handle->intr_vec == NULL) {
+   PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
+   " intr_vec\n", 
dev->data->nb_rx_queues);
+   return -ENOMEM;
+   }
+
+   /* enable rx interrupt */
+   em_rxq_intr_enable(hw);
+   }
+
eth_em_tx_init(dev);

ret = eth_em_rx_init(dev);
@@ -621,6 +643,8 @@ eth_em_start(struct rte_eth_dev *dev)
if (dev->data->dev_conf.intr_conf.rxq != 0)
eth_em_rxq_interrupt_setup(dev);

+   rte_intr_enable(intr_handle);
+
adapter->stopped = 0;

PMD_INIT_LOG(DEBUG, "<<");
@@ -646,6 +670,7 @@ eth_em_stop(struct rte_eth_dev *dev)
 {
struct rte_eth_link link;
struct e1000_hw *hw = E1000_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+   struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle;

em_rxq_intr_disable(hw);
em_lsc_intr_disable(hw);
@@ -662,6 +687,13 @@ eth_em_stop(struct rte_eth_dev *dev)
/* clear the recorded link status */
memset(&link, 0, sizeof(link));
rte_em_dev_atomic_write_link_status(dev, &link);
+
+   /* Clean datapath event and queue/vec mapping */
+   rte_intr_efd_disable(intr_handle);
+   if (intr_handle->intr_vec != NULL) {
+   rte_free(intr_handle->intr_vec);
+   intr_handle->intr_vec = NULL;
+   }
 }

 static void
-- 
1.9.3



[dpdk-dev] [PATCH v3 8/8] doc: release note update for e1000 intr mode

2015-10-29 Thread Yong Liu
Signed-off-by: Marvin Liu 

diff --git a/doc/guides/rel_notes/release_2_2.rst 
b/doc/guides/rel_notes/release_2_2.rst
index be6f827..7655148 100644
--- a/doc/guides/rel_notes/release_2_2.rst
+++ b/doc/guides/rel_notes/release_2_2.rst
@@ -23,6 +23,7 @@ New Features

 * **Added vhost-user multiple queue support.**

+* **Support interrupt mode on e1000.**

 Resolved Issues
 ---
-- 
1.9.3



[dpdk-dev] [PATCH v6 1/3] i40e: RSS/FD granularity configuration

2015-10-29 Thread Bruce Richardson
On Thu, Oct 29, 2015 at 02:02:50PM +0800, Helin Zhang wrote:
> The default input set of fields of a received packet are loaded from
> firmware, which cannot be modified even users want to use different
> fields for RSS or flow director. Here adds more flexibilities of
> selecting packet fields for hash calculation or flow director for
> users.
> 
> Signed-off-by: Helin Zhang 
> Signed-off-by: Andrey Chilikin 
> ---
>  drivers/net/i40e/i40e_ethdev.c  | 742 
> 
>  drivers/net/i40e/i40e_ethdev.h  |   7 +
>  drivers/net/i40e/i40e_fdir.c|  31 ++
>  lib/librte_ether/rte_eth_ctrl.h | 114 +-
>  4 files changed, 890 insertions(+), 4 deletions(-)
> 

> @@ -672,6 +776,8 @@ struct rte_eth_hash_filter_info {
>   uint8_t enable;
>   /** Global configurations of hash filter */
>   struct rte_eth_hash_global_conf global_conf;
> + /** Global configurations of hash filter input set */
> + struct rte_eth_input_set_conf input_set_conf;
>   } info;
>  };
>
Hi Helin,

Just to check: Does this change affect the size of the structure and cause ABI
issues?

/Bruce


[dpdk-dev] [PATCH v4 1/1] ip_pipeline: added dynamic pipeline reconfiguration

2015-10-29 Thread Piotr Azarewicz
Up till now pipeline was bound to thread selected in the initial config.
This patch allows binding pipeline to other threads at runtime using CLI
commands.

v2 changes:
- deleted debug printfs

v3 changes:
- add timer for thread message request
- fix bug that the new functionality can't work
- fix leaking memory
- cleaning up

v4 changes:
- fix compilation with gcc 5.1
- add proper checking if thread exist

Signed-off-by: Maciej Gajdzica 
Signed-off-by: Piotr Azarewicz 

Acked-by: Cristian Dumitrescu 
---
 examples/ip_pipeline/Makefile  |1 +
 examples/ip_pipeline/app.h |   12 +
 examples/ip_pipeline/config_parse.c|2 +-
 examples/ip_pipeline/init.c|   24 ++
 examples/ip_pipeline/pipeline.h|6 +
 examples/ip_pipeline/pipeline/pipeline_common_fe.h |3 +
 examples/ip_pipeline/thread.c  |  153 -
 examples/ip_pipeline/thread.h  |   84 +
 examples/ip_pipeline/thread_fe.c   |  350 
 examples/ip_pipeline/thread_fe.h   |   95 ++
 10 files changed, 728 insertions(+), 2 deletions(-)
 create mode 100644 examples/ip_pipeline/thread.h
 create mode 100644 examples/ip_pipeline/thread_fe.c
 create mode 100644 examples/ip_pipeline/thread_fe.h

diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index f3ff1ec..c8e80b5 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -54,6 +54,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_parse_tm.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += config_check.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += init.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread.c
+SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += thread_fe.c
 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += cpu_core_map.c

 SRCS-$(CONFIG_RTE_LIBRTE_PIPELINE) += pipeline_common_be.c
diff --git a/examples/ip_pipeline/app.h b/examples/ip_pipeline/app.h
index 521e3a0..3a57956 100644
--- a/examples/ip_pipeline/app.h
+++ b/examples/ip_pipeline/app.h
@@ -220,9 +220,11 @@ struct app_pipeline_data {
void *be;
void *fe;
uint64_t timer_period;
+   uint32_t enabled;
 };

 struct app_thread_pipeline_data {
+   uint32_t pipeline_id;
void *be;
pipeline_be_op_run f_run;
pipeline_be_op_timer f_timer;
@@ -234,6 +236,10 @@ struct app_thread_pipeline_data {
 #define APP_MAX_THREAD_PIPELINES 16
 #endif

+#ifndef APP_THREAD_TIMER_PERIOD
+#define APP_THREAD_TIMER_PERIOD  1
+#endif
+
 struct app_thread_data {
struct app_thread_pipeline_data regular[APP_MAX_THREAD_PIPELINES];
struct app_thread_pipeline_data custom[APP_MAX_THREAD_PIPELINES];
@@ -241,7 +247,13 @@ struct app_thread_data {
uint32_t n_regular;
uint32_t n_custom;

+   uint64_t timer_period;
+   uint64_t thread_req_deadline;
+
uint64_t deadline;
+
+   struct rte_ring *msgq_in;
+   struct rte_ring *msgq_out;
 };

 struct app_eal_params {
diff --git a/examples/ip_pipeline/config_parse.c 
b/examples/ip_pipeline/config_parse.c
index c9b78f9..d2aaadf 100644
--- a/examples/ip_pipeline/config_parse.c
+++ b/examples/ip_pipeline/config_parse.c
@@ -362,7 +362,7 @@ parser_read_uint32(uint32_t *value, const char *p)
return 0;
 }

-static int
+int
 parse_pipeline_core(uint32_t *socket,
uint32_t *core,
uint32_t *ht,
diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index 3f9c68d..8c63879 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -50,6 +50,7 @@
 #include "pipeline_firewall.h"
 #include "pipeline_flow_classification.h"
 #include "pipeline_routing.h"
+#include "thread_fe.h"

 #define APP_NAME_SIZE  32

@@ -1253,6 +1254,25 @@ app_init_threads(struct app_params *app)

t = &app->thread_data[lcore_id];

+   t->timer_period = (rte_get_tsc_hz() * APP_THREAD_TIMER_PERIOD) 
/ 1000;
+   t->thread_req_deadline = time + t->timer_period;
+
+   t->msgq_in = app_thread_msgq_in_get(app,
+   params->socket_id,
+   params->core_id,
+   params->hyper_th_id);
+   if (t->msgq_in == NULL)
+   rte_panic("Init error: Cannot find MSGQ_IN for thread 
%" PRId32,
+   lcore_id);
+
+   t->msgq_out = app_thread_msgq_out_get(app,
+   params->socket_id,
+   params->core_id,
+   params->hyper_th_id);
+   if (t->msgq_out == NULL)
+   rte_panic("Init error: Cannot find MSGQ_OUT for thread 
%" PRId32,
+   lcore_id);
+
ptype = app_pipeline_type_find(app, params->type);
if (ptype == NULL)

[dpdk-dev] [PATCH v3 0/2] i40e: Fix the statistics issue of i40e

2015-10-29 Thread Van Haaren, Harry
Hi Xutao,

> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Xutao Sun
> Sent: Thursday, October 29, 2015 8:02 AM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH v3 0/2] i40e: Fix the statistics issue of i40e
> 
> The old statistics on i40e only counted the packets on ports.
> So the discarding packets on VSI were not counted.
> This patch is to make statistics for packets both on ports and VSI.

Indeed there is an issue in i40e stats, and adding the VSI stats to the port 
stats seems the right fix.

> Xutao Sun (2):
>   i40e: Fix the statistics issue of i40e
>   doc: update release notes
> 
>  doc/guides/rel_notes/release_2_1.rst |  5 +
>  drivers/net/i40e/i40e_ethdev.c   | 23 ++-
>  2 files changed, 19 insertions(+), 9 deletions(-)

It is preferred to update docs in the same patch as a bugfix: one patch should 
suffice for a bug-fix and adding a note that it has been fixed.

Perhaps you edited the wrong release file? The next release changes are 
described in release_2_2.rst

Would you send a v4 with release_2_2 updated, and then I'll test and ack?
Cheers, -Harry


[dpdk-dev] [PATCH] lib/lpm:fix two issues in the delete_depth_small()

2015-10-29 Thread Bruce Richardson
On Thu, Oct 29, 2015 at 10:41:45AM +0800, nana.nn wrote:
> Hi Bruce:
>   Should I send the test unit as a DPDK patch, or just the program for 
> you to demonstrate the bugs? 
> 
>   
>   Thank you very much!
> 
> 
> Regards
> 
> Na Na
> 

A patch to add a unit test for the bug would be best.
/Bruce

> 
> 
> 
> On Oct 28, 2015, at 10:40 PM, Bruce Richardson  intel.com> wrote:
> 
> > On Wed, Oct 28, 2015 at 11:44:15AM +0800, Jijiang Liu wrote:
> >> Fix two issues in the delete_depth_small() function.
> >> 
> >> 1> The control is not strict in this function.
> >> 
> >> In the following structure,
> >> struct rte_lpm_tbl24_entry {
> >>union {
> >>uint8_t next_hop;
> >>uint8_t tbl8_gindex;
> >>};
> >> uint8_t ext_entry :1;
> >> }
> >> 
> >> When ext_entry = 0, use next_hop.only to process rte_lpm_tbl24_entry.
> >> 
> >> When ext_entry = 1, use tbl8_gindex to process the rte_lpm_tbl8_entry.
> >> 
> >> When using LPM24 + 8 algorithm, it will use ext_entry to decide to process 
> >> rte_lpm_tbl24_entry structure or rte_lpm_tbl8_entry structure. 
> >> If a route is deleted, the prefix of previous route is used to override 
> >> the deleted route. when (lpm->tbl24[i].ext_entry == 0 && 
> >> lpm->tbl24[i].depth > depth) 
> >> it should be ignored, but due to the incorrect logic, the next_hop is used 
> >> as tbl8_gindex and will process the rte_lpm_tbl8_entry.
> >> 
> >> 2> Initialization of rte_lpm_tbl8_entry is incorrect in this function 
> >> 
> >> In this function, use new rte_lpm_tbl8_entry we call A to replace the old 
> >> rte_lpm_tbl8_entry. But the valid_group do not set VALID, so it will be 
> >> INVALID.
> >> Then when adding a new route which depth is > 24,the tbl8_alloc() function 
> >> will search the rte_lpm_tbl8_entrys to find INVALID valid_group, 
> >> and it will return the A to the add_depth_big function, so A's data is 
> >> overridden.
> >> 
> >> Signed-off-by: NaNa 
> >> 
> > 
> > Hi NaNa, Jijiang,
> > 
> > since this patch contains two separate fixes, it would be better split into
> > two separate patches, one for each fix. Also, please add a "Fixes" line to
> > the commit log.
> > 
> > Are there still plans for a unit test to demonstrate the bug(s) and make it 
> > easy
> > for us to verify the fix?
> > 
> > Regards,
> > /Bruce
> 




[dpdk-dev] [PATCH v3 0/8] interrupt mode for e1000

2015-10-29 Thread Liang, Cunming
Hi,

> -Original Message-
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Yong Liu
> Sent: Thursday, October 29, 2015 5:19 PM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [PATCH v3 0/8] interrupt mode for e1000
> 
> This patch set will enable interrup for physical and emulated e1000 device.
> Rx queue interrupt will work with uio driver or vfio driver with msi mode.
> l3fwd-power will disable interrupt immediately when wake-up for that e1000 not
> support interrupt auto clear.
> LSC and rxq interrupt will be seperated for e1000 can only support one
> interrupt cause in the same time.
> 
> The patch set is developed based on one previous patch set
> "[PATCH v1 00/11] interrupt mode for i40e"
> http://www.dpdk.org/ml/archives/dev/2015-September/023903.html
> 
> v3 changes:
> add in release note
> 
> v2 changes:
> describe interrupt mode work with uio and vfio+msi
> replace attribuite __unused__ with __rte_unused
> 
> Marvin Liu (8):
>   e1000: add rx interrupt support
>   e1000: separate lsc and rxq interrupt disable function
>   e1000: add ethdev rxq enable and disable function
>   e1000: add rxq interrupt handler
>   e1000: check lsc and rxq not enable in the same time
>   e1000: lsc interrupt setup function only enable itself
>   l3fwd-power: disable interrupt when wake up from sleep
>   doc: release note update for e1000 intr mode
> 
>  doc/guides/rel_notes/release_2_2.rst |   1 +
>  drivers/net/e1000/em_ethdev.c| 181
> +++
>  examples/l3fwd-power/main.c  |   1 +
>  3 files changed, 164 insertions(+), 19 deletions(-)
> 
> --
> 1.9.3

Acked-by: Cunming Liang 



[dpdk-dev] [PATCH v4 00/16] Vector Rx/Tx PMD implementation for fm10k

2015-10-29 Thread Liang, Cunming
Hi,

> -Original Message-
> From: Chen, Jing D
> Sent: Thursday, October 29, 2015 5:16 PM
> To: dev at dpdk.org
> Cc: Liang, Cunming; Tao, Zhe; He, Shaopeng; Ananyev, Konstantin; Richardson,
> Bruce; Chen, Jing D
> Subject: [PATCH v4 00/16] Vector Rx/Tx PMD implementation for fm10k
> 
> From: "Chen Jing D(Mark)" 
> 
> v4:
>  - Clear HW/SW ring content after allocating mbuf failed.
> 
> v3:
>  - Add a blank line after variable definition.
>  - Do floor alignment for passing in argument nb_pkts to avoid memory
> overwritten.
>  - Only scan max of 32 desc in scatter Rx function to avoid memory 
> overwritten.
> 
> v2:
>  - Fix a typo issue.
>  - Fix an improper prefetch in vector RX function, in which prefetches
>un-initialized mbuf.
>  - Remove limitation on number of desc pointer in vector RX function.
>  - Re-organize some comments.
>  - Add a new patch to fix a crash issue in vector RX func.
>  - Add a new patch to update release notes.
> 
> v1:
> This patch set includes Vector Rx/Tx functions to receive/transmit packets
> for fm10k devices. It also contains logic to do sanity check for proper
> RX/TX function selections.
> 
> Chen Jing D(Mark) (16):
>   fm10k: add new vPMD file
>   fm10k: add vPMD pre-condition check for each RX queue
>   fm10k: Add a new func to initialize all parameters
>   fm10k: add func to re-allocate mbuf for RX ring
>   fm10k: add 2 functions to parse pkt_type and offload flag
>   fm10k: add Vector RX function
>   fm10k: add func to do Vector RX condition check
>   fm10k: add Vector RX scatter function
>   fm10k: add function to decide best RX function
>   fm10k: add func to release mbuf in case Vector RX applied
>   fm10k: add Vector TX function
>   fm10k: use func pointer to reset TX queue and mbuf release
>   fm10k: introduce 2 funcs to reset TX queue and mbuf release
>   fm10k: Add function to decide best TX func
>   fm10k: fix a crash issue in vector RX func
>   doc: release notes update for fm10k Vector PMD
> 
>  doc/guides/rel_notes/release_2_2.rst |5 +
>  drivers/net/fm10k/Makefile   |1 +
>  drivers/net/fm10k/fm10k.h|   45 ++-
>  drivers/net/fm10k/fm10k_ethdev.c |  169 ++-
>  drivers/net/fm10k/fm10k_rxtx_vec.c   |  847
> ++
>  5 files changed, 1039 insertions(+), 28 deletions(-)
>  create mode 100644 drivers/net/fm10k/fm10k_rxtx_vec.c
> 
> --
> 1.7.7.6

Acked-by: Cunming Liang 



[dpdk-dev] 答复: [PATCH] lib/lpm:fix two issues in the delete_depth_small()

2015-10-29 Thread 那娜(恒月)
HI Bruce:How about this, I send you the test program , then you 
can?demonstrate?the?bugs .? ? If you?demonstrate?the?bugs ,then you can get the 
lpm bug's fix into?the?release first.Further ,we explicitly discuss the 
details about the unit test and make it a patch of dpdk.Thank you very much!
Regards
Na Na




--Bruce 
Richardson ?2015?10?29?(???) 18:18??(??) 
Jijiang Liu ?dev Re: [dpdk-dev] [PATCH] lib/lpm:fix two issues in the 
delete_depth_small()
On?Thu,?Oct?29,?2015?at?10:41:45AM?+0800,?nana.nn?wrote:
>?Hi?Bruce:
>??Should?I?send?the?test?unit?as?a?DPDK?patch,?or?just?the?program?for?you?to?demonstrate?the?bugs??
>?
>??
>??Thank?you?very?much!
>?
>?
>?Regards
>?
>?Na?Na
>?

A?patch?to?add?a?unit?test?for?the?bug?would?be?best.
/Bruce

>?
>?
>?
>?On?Oct?28,?2015,?at?10:40?PM,?Bruce?Richardson?intel.com>?wrote:
>?
>?>?On?Wed,?Oct?28,?2015?at?11:44:15AM?+0800,?Jijiang?Liu?wrote:
>?>>?Fix?two?issues?in?the?delete_depth_small()?function.
>?>>?
>?>>?1>?The?control?is?not?strict?in?this?function.
>?>>?
>?>>?In?the?following?structure,
>?>>?struct?rte_lpm_tbl24_entry?{
>?>>union?{
>?>>uint8_t?next_hop;
>?>>uint8_t?tbl8_gindex;
>?>>};
>?>>?uint8_t?ext_entry?:1;
>?>>?}
>?>>?
>?>>?When?ext_entry?=?0,?use?next_hop.only?to?process?rte_lpm_tbl24_entry.
>?>>?
>?>>?When?ext_entry?=?1,?use?tbl8_gindex?to?process?the?rte_lpm_tbl8_entry.
>?>>?
>?>>?When?using?LPM24?+?8?algorithm,?it?will?use?ext_entry?to?decide?to?process?rte_lpm_tbl24_entry?structure?or?rte_lpm_tbl8_entry?structure.?
>?>>?If?a?route?is?deleted,?the?prefix?of?previous?route?is?used?to?override?the?deleted?route.?when?(lpm->tbl24[i].ext_entry?==?0?&&?lpm->tbl24[i].depth?>?depth)?
>?>>?it?should?be?ignored,?but?due?to?the?incorrect?logic,?the?next_hop?is?used?as?tbl8_gindex?and?will?process?the?rte_lpm_tbl8_entry.
>?>>?
>?>>?2>?Initialization?of?rte_lpm_tbl8_entry?is?incorrect?in?this?function?
>?>>?
>?>>?In?this?function,?use?new?rte_lpm_tbl8_entry?we?call?A?to?replace?the?old?rte_lpm_tbl8_entry.?But?the?valid_group?do?not?set?VALID,?so?it?will?be?INVALID.
>?>>?Then?when?adding?a?new?route?which?depth?is?>?24,the?tbl8_alloc()?function?will?search?the?rte_lpm_tbl8_entrys?to?find?INVALID?valid_group,?
>?>>?and?it?will?return?the?A?to?the?add_depth_big?function,?so?A's?data?is?overridden.
>?>>?
>?>>?Signed-off-by:?NaNa?
>?>>?
>?>?
>?>?Hi?NaNa,?Jijiang,
>?>?
>?>?since?this?patch?contains?two?separate?fixes,?it?would?be?better?split?into
>?>?two?separate?patches,?one?for?each?fix.?Also,?please?add?a?"Fixes"?line?to
>?>?the?commit?log.
>?>?
>?>?Are?there?still?plans?for?a?unit?test?to?demonstrate?the?bug(s)?and?make?it?easy
>?>?for?us?to?verify?the?fix?
>?>?
>?>?Regards,
>?>?/Bruce
>?



[dpdk-dev] [PATCH] doc: remove dejavu font from doc build

2015-10-29 Thread Mcnamara, John


> -Original Message-
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> Sent: Monday, October 26, 2015 2:25 PM
> To: Mcnamara, John
> Cc: dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] doc: remove dejavu font from doc build
> 
> 2015-10-20 12:32, John McNamara:
> > Remove requirement for occasionally hard to find/install
> > DejaVuSansMono font. It isn't gnerally required anyway.
> > The default mono font is sufficient.
> 
> Does it remove the need for texlive-collection-fontsextra?

Hi,

I checked and it does remove the requirement for texlive-fonts-recommended in 
Ubuntu and texlive-collection-fontsextra in Fedora.

I'll submit a v2 with those requirements removed from the Documentation 
Guidelines.

John.
-- 




[dpdk-dev] [PATCH v5 21/28] librte_ether: remove branches on pci_dev

2015-10-29 Thread Bruce Richardson
On Fri, Oct 23, 2015 at 06:36:26PM +0100, Bernard Iremonger wrote:
> use dev_type to distinguish between vdev's and pdev's.
> remove pci_dev branches.
> update release notes.
> 
> Signed-off-by: Bernard Iremonger 
> ---
>  doc/guides/rel_notes/release_2_2.rst |  3 +++
>  lib/librte_ether/rte_ethdev.c| 40 
> +++-
>  2 files changed, 20 insertions(+), 23 deletions(-)
> 
  
>  /* attach the new physical device, then store port_id of the device */
> @@ -1143,14 +1141,11 @@ rte_eth_dev_configure(uint8_t port_id, uint16_t 
> nb_rx_q, uint16_t nb_tx_q,
>* If link state interrupt is enabled, check that the
>* device supports it.
>*/
> - if (dev_conf->intr_conf.lsc == 1) {
> - const struct rte_pci_driver *pci_drv = &dev->driver->pci_drv;
> -
> - if (!(pci_drv->drv_flags & RTE_PCI_DRV_INTR_LSC)) {
> + if ((dev_conf->intr_conf.lsc == 1) &&
> + (!(dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC))) {
>   PMD_DEBUG_TRACE("driver %s does not support lsc\n",
> - pci_drv->name);
> + dev->data->drv_name);

Is this safe to do? From your previous patches for the vdevs, you appear to be
setting the drv_name field to NULL for those vdevs, leading to undefined
behaviour here. (printf may catch the NULL and print it as "(null)" rather
than crashing, but it's still wrong!)

/Bruce



[dpdk-dev] [PATCH v4 0/2] User-space ethtool sample application

2015-10-29 Thread Remy Horton
Further enhancements to the userspace ethtool implementation that was
submitted in 2.1 and packaged as a self-contained sample application.
Implements an rte_ethtool shim layer based on rte_ethdev API, along
with a command prompt driven demonstration application.

This patchset depends on:
* http://dpdk.org/dev/patchwork/patch/6563/
* http://dpdk.org/dev/patchwork/patch/8070/

v4:
* Fixed assumption that master core always has id zero
* Changed 1:1 core-to-port to 2 core (ethtool & ports) design 
* Included the correct documentation..

v3:
* Made use of enums for core state.
* Fixed Makefile issue.
* Fixed incorrect assumption with core ids.
* Changed handling of more ports than cores.

v2:
* Replaced l2fwd base with simpler application.
* Added ringparam functions.
* Added documentation.

Remy Horton (2):
  example: User-space ethtool sample application
  doc: add user-space ethtool sample app guide

 doc/guides/sample_app_ug/ethtool.rst  | 265 +++
 doc/guides/sample_app_ug/index.rst|   1 +
 examples/ethtool/Makefile |  48 ++
 examples/ethtool/ethtool-app/Makefile |  54 +++
 examples/ethtool/ethtool-app/ethapp.c | 873 ++
 examples/ethtool/ethtool-app/ethapp.h |  41 ++
 examples/ethtool/ethtool-app/main.c   | 297 
 examples/ethtool/lib/Makefile |  57 +++
 examples/ethtool/lib/rte_ethtool.c| 421 
 examples/ethtool/lib/rte_ethtool.h| 410 
 10 files changed, 2467 insertions(+)
 create mode 100644 doc/guides/sample_app_ug/ethtool.rst
 create mode 100644 examples/ethtool/Makefile
 create mode 100644 examples/ethtool/ethtool-app/Makefile
 create mode 100644 examples/ethtool/ethtool-app/ethapp.c
 create mode 100644 examples/ethtool/ethtool-app/ethapp.h
 create mode 100644 examples/ethtool/ethtool-app/main.c
 create mode 100644 examples/ethtool/lib/Makefile
 create mode 100644 examples/ethtool/lib/rte_ethtool.c
 create mode 100644 examples/ethtool/lib/rte_ethtool.h

-- 
1.9.3



[dpdk-dev] [PATCH v4 1/2] example: add user-space ethtool sample application

2015-10-29 Thread Remy Horton
Further enhancements to the userspace ethtool implementation that was
submitted in 2.1 and packaged as a self-contained sample application.
Implements an rte_ethtool shim layer based on rte_ethdev API, along
with a command prompt driven demonstration application.

Signed-off-by: Remy Horton 
---
 examples/ethtool/Makefile |  48 ++
 examples/ethtool/ethtool-app/Makefile |  54 +++
 examples/ethtool/ethtool-app/ethapp.c | 873 ++
 examples/ethtool/ethtool-app/ethapp.h |  41 ++
 examples/ethtool/ethtool-app/main.c   | 297 
 examples/ethtool/lib/Makefile |  57 +++
 examples/ethtool/lib/rte_ethtool.c| 421 
 examples/ethtool/lib/rte_ethtool.h| 410 
 8 files changed, 2201 insertions(+)
 create mode 100644 examples/ethtool/Makefile
 create mode 100644 examples/ethtool/ethtool-app/Makefile
 create mode 100644 examples/ethtool/ethtool-app/ethapp.c
 create mode 100644 examples/ethtool/ethtool-app/ethapp.h
 create mode 100644 examples/ethtool/ethtool-app/main.c
 create mode 100644 examples/ethtool/lib/Makefile
 create mode 100644 examples/ethtool/lib/rte_ethtool.c
 create mode 100644 examples/ethtool/lib/rte_ethtool.h

diff --git a/examples/ethtool/Makefile b/examples/ethtool/Makefile
new file mode 100644
index 000..94f8ee3
--- /dev/null
+++ b/examples/ethtool/Makefile
@@ -0,0 +1,48 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2015 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 overwritten by command line or environment
+RTE_TARGET ?= x86_64-native-linuxapp-gcc
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+ifneq ($(CONFIG_RTE_EXEC_ENV),"linuxapp")
+$(error This application can only operate in a linuxapp environment, \
+please change the definition of the RTE_TARGET environment variable)
+endif
+
+DIRS-y += lib ethtool-app
+
+include $(RTE_SDK)/mk/rte.extsubdir.mk
diff --git a/examples/ethtool/ethtool-app/Makefile 
b/examples/ethtool/ethtool-app/Makefile
new file mode 100644
index 000..09c66ad
--- /dev/null
+++ b/examples/ethtool/ethtool-app/Makefile
@@ -0,0 +1,54 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2010-2014 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

[dpdk-dev] [PATCH v4 2/2] doc: add user-space ethtool sample app guide

2015-10-29 Thread Remy Horton
Signed-off-by: Remy Horton 
---
 doc/guides/sample_app_ug/ethtool.rst | 265 +++
 doc/guides/sample_app_ug/index.rst   |   1 +
 2 files changed, 266 insertions(+)
 create mode 100644 doc/guides/sample_app_ug/ethtool.rst

diff --git a/doc/guides/sample_app_ug/ethtool.rst 
b/doc/guides/sample_app_ug/ethtool.rst
new file mode 100644
index 000..f048dd9
--- /dev/null
+++ b/doc/guides/sample_app_ug/ethtool.rst
@@ -0,0 +1,265 @@
+
+..  BSD LICENSE
+Copyright(c) 2015 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.
+
+EthTool Sample Application
+==
+
+The Ethtool sample application shows an implementation of an
+EthTool-like API and provides a console environment that allows
+its use to query and change Ethernet card parameters. The sample
+is based upon a simple L2 frame reflector.
+
+
+Compiling the Application
+-
+
+To compile the application:
+
+#.  Go to the sample application directory:
+
+.. code-block:: console
+
+export RTE_SDK=/path/to/rte_sdk cd ${RTE_SD}/examples/ethtool
+
+#.  Set the target (a default target is used if not specified). For example:
+
+.. code-block:: console
+
+export RTE_TARGET=x86_64-native-linuxapp-gcc
+
+See the *DPDK Getting Started Guide* for possible RTE_TARGET values.
+
+#.  Build the application:
+
+.. code-block:: console
+
+make
+
+Running the Application
+---
+
+The application requires an available core for each port, plus one.
+The only available options are the standard ones for the EAL:
+
+.. code-block:: console
+
+./build/ethtool [EAL options]
+
+Refer to the *DPDK Getting Started Guide* for general information on
+running applications and the Environment Abstraction Layer (EAL)
+options.
+
+Using the application
+-
+
+The application is console-driven using the cmdline DPDK interface:
+
+.. code-block:: console
+
+EthApp>
+
+From this interface the available commands and descriptions of what
+they do as as follows:
+
+drvinfo
+Print driver info
+eeprom
+Dump EEPROM to file
+link
+Print port link states
+macaddr
+Gets/sets MAC address
+mtu
+Set NIC MTU
+open
+Open port
+pause
+Get/set port pause state
+portstats
+Print port statistics
+regs
+Dump port register(s) to file
+ringparam
+Get/set ring parameters
+rxmode
+Toggle port Rx mode
+stop
+Stop port
+validate
+Check that given MAC address is valid unicast address
+vlan
+Add/remove VLAN id
+quit
+Exit program
+
+
+Explaination
+
+
+The following sections describe the most important parts of the code.
+
+
+Base program
+
+
+The top-level, after some port initialisation routines, runs the following:
+
+.. code-block:: c
+
+   for (idx_port = 0; idx_port < cnt_ports; idx_port++) {
+   ptr_port = &app_cfg.ports[idx_port];
+   rte_eal_remote_launch(slave_main, ptr_port, idx_port + 1);
+   }
+
+   ethapp_main();
+
+Each slave core, or a subset of these cores if there are more cores then
+NIC ports, runs the `slave core process`_ described below. The master core
+then runs the `EthTool App`_ itself.
+
+
+Slave core process
+~~
+
+Each slave core is assigned one of the available ports, and runs
+the following code that implements a

[dpdk-dev] [PATCH 1/2] scripts: add checkpatch wrapper

2015-10-29 Thread Bruce Richardson
On Fri, Oct 23, 2015 at 05:53:25PM +0200, Thomas Monjalon wrote:
> This script can be used to call checkpatch.pl from Linux with some
> custom DPDK options.
> 
> The path to the original Linux script must be set in an environment
> variable. A script is added to load any configuration variables
> required by development tools from a file .develconfig, or
> ~/.config/dpdk/devel.config or /etc/dpdk/devel.config.
> 
> Signed-off-by: Thomas Monjalon 

Be great to have this in the repo for checking patches before ack.

Acked-by: Bruce Richardson 


[dpdk-dev] [PATCH v5 00/28] remove pci driver from vdevs

2015-10-29 Thread Bruce Richardson
On Fri, Oct 23, 2015 at 06:36:05PM +0100, Bernard Iremonger wrote:
> There is a dummy pci driver in the vdev PMD's at present.
> This patch set removes the pci driver from the vdev PMD's.
> Changes have been made to librte_ether to handle vdevs and pdevs in the same 
> way.
> 
> The following vdev PMD's have had the pci driver removed:
> 
> null
> ring
> bonding
> pcap
> af_packet
> xenvirt
> mpipe
> 
> All the pdev PMD's have been modified to copy the pci device info into 
> eth_dev data.
>
Apart from the one query on patch 21, all looks ok to me.

Series Acked-by: Bruce Richardson 



[dpdk-dev] [PATCH] hash: fix scaling by reducing contention

2015-10-29 Thread Pablo de Lara
If using multiple cores on a system with hardware transactional
memory support, thread scaling does not work, as there was a single
point in the hash library which is a bottleneck for all threads,
which is the "free_slots" ring, which stores all the indices of
the free slots in the table.

This patch fixes the problem, by creating a local cache per logical core,
which stores locally indices of free slots,
so most times, writer threads will not interfere each other.

Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")

Signed-off-by: Pablo de Lara 
---
 app/test/test_hash_scaling.c |   1 +
 doc/guides/rel_notes/release_2_2.rst |   5 ++
 lib/librte_hash/rte_cuckoo_hash.c| 144 ++-
 lib/librte_hash/rte_hash.h   |   3 +
 4 files changed, 133 insertions(+), 20 deletions(-)

diff --git a/app/test/test_hash_scaling.c b/app/test/test_hash_scaling.c
index 39602cb..e7cb7e2 100644
--- a/app/test/test_hash_scaling.c
+++ b/app/test/test_hash_scaling.c
@@ -133,6 +133,7 @@ test_hash_scaling(int locking_mode)
.hash_func = rte_hash_crc,
.hash_func_init_val = 0,
.socket_id = rte_socket_id(),
+   .extra_flag = 1 << RTE_HASH_TRANS_MEM_SUPPORT_FLAG,
};
struct rte_hash *handle;
char name[RTE_HASH_NAMESIZE];
diff --git a/doc/guides/rel_notes/release_2_2.rst 
b/doc/guides/rel_notes/release_2_2.rst
index 834ac43..8727d63 100644
--- a/doc/guides/rel_notes/release_2_2.rst
+++ b/doc/guides/rel_notes/release_2_2.rst
@@ -56,6 +56,11 @@ Drivers

   Fixed issue when releasing null control queue.

+* **hash: Fixed thread scaling by reducing contention.**
+
+  Fixed issue in hash library where, using multiple cores with
+  hardware transactional memory support, thread scaling did not work,
+  due to the global ring that is shared by all cores.

 Libraries
 ~
diff --git a/lib/librte_hash/rte_cuckoo_hash.c 
b/lib/librte_hash/rte_cuckoo_hash.c
index 409fc2e..43788a4 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -96,8 +96,15 @@ EAL_REGISTER_TAILQ(rte_hash_tailq)

 #define KEY_ALIGNMENT  16

+#define LCORE_CACHE_SIZE   8
+
 typedef int (*rte_hash_cmp_eq_t)(const void *key1, const void *key2, size_t 
key_len);

+struct lcore_cache {
+   unsigned len; /**< Cache len */
+   void *objs[LCORE_CACHE_SIZE]; /**< Cache objects */
+} __rte_cache_aligned;
+
 /** A hash table structure. */
 struct rte_hash {
char name[RTE_HASH_NAMESIZE];   /**< Name of the hash. */
@@ -117,6 +124,10 @@ struct rte_hash {
struct rte_hash_bucket *buckets;/**< Table with buckets storing 
all the
hash values and key 
indexes
to the key table*/
+   uint8_t hw_trans_mem_support;   /**< Hardware transactional
+   memory support */
+   struct lcore_cache *local_free_slots;
+   /**< Local cache per lcore, storing some indexes of the free slots */
 } __rte_cache_aligned;

 /* Structure storing both primary and secondary hashes */
@@ -183,6 +194,8 @@ rte_hash_create(const struct rte_hash_parameters *params)
void *k = NULL;
void *buckets = NULL;
char ring_name[RTE_RING_NAMESIZE];
+   unsigned num_key_slots;
+   unsigned hw_trans_mem_support = 0;
unsigned i;

hash_list = RTE_TAILQ_CAST(rte_hash_tailq.head, rte_hash_list);
@@ -202,6 +215,10 @@ rte_hash_create(const struct rte_hash_parameters *params)
return NULL;
}

+   /* Check extra flags bit to check extra options. */
+   if (params->extra_flag & (1 << RTE_HASH_TRANS_MEM_SUPPORT_FLAG))
+   hw_trans_mem_support = 1;
+
snprintf(hash_name, sizeof(hash_name), "HT_%s", params->name);

/* Guarantee there's no existing */
@@ -238,7 +255,18 @@ rte_hash_create(const struct rte_hash_parameters *params)
const uint32_t key_entry_size = sizeof(struct rte_hash_key) + 
params->key_len;

/* Store all keys and leave the first entry as a dummy entry for 
lookup_bulk */
-   const uint64_t key_tbl_size = (uint64_t) key_entry_size * 
(params->entries + 1);
+   if (hw_trans_mem_support)
+   /*
+* Increase number of slots by total number of indices
+* that can be stored in the lcore caches
+* except for the first cache
+*/
+   num_key_slots = params->entries + (RTE_MAX_LCORE - 1) *
+   LCORE_CACHE_SIZE + 1;
+   else
+   num_key_slots = params->entries + 1;
+
+   const uint64_t key_tbl_size = (uint64_t) key_entry_size * num_key_slots;

k = rte_zmalloc_socket(NULL, key_tbl_size,
RTE_CACHE_LINE_SIZE, params->socket_id);
@@ -

[dpdk-dev] [PATCH] doc: remove dejavu font from doc build

2015-10-29 Thread Thomas Monjalon
2015-10-29 11:35, Mcnamara, John:
> From: Thomas Monjalon [mailto:thomas.monjalon at 6wind.com]
> > 2015-10-20 12:32, John McNamara:
> > > Remove requirement for occasionally hard to find/install
> > > DejaVuSansMono font. It isn't gnerally required anyway.
> > > The default mono font is sufficient.
> > 
> > Does it remove the need for texlive-collection-fontsextra?
> 
> Hi,
> 
> I checked and it does remove the requirement for texlive-fonts-recommended in 
> Ubuntu and texlive-collection-fontsextra in Fedora.
> 
> I'll submit a v2 with those requirements removed from the Documentation 
> Guidelines.

Please remove it from the RPM packaging script also.
Thanks


[dpdk-dev] [PATCH 1/2] scripts: add checkpatch wrapper

2015-10-29 Thread David Marchand
On Fri, Oct 23, 2015 at 5:53 PM, Thomas Monjalon 
wrote:

> +for p in "$@" ; do
> +   printf -- "\n### $p\n\n"
> +   report=$($DPDK_CHECKPATCH_PATH $options "$p" 2>/dev/null)
> +   [ $? -ne 0 ] || continue
> +   printf '%s\n' "$report" | head -n -6
> +   status=$(($status + 1))
> +done
> +exit $status
>

I prefer when checking scripts only complain when something is wrong :-)
So I would only display the file name if checkpatch complains.

-- 
David Marchand


[dpdk-dev] [PATCH 3/8] driver/virtio:add vhost TX offload support capability in virtio-net

2015-10-29 Thread David Marchand
Hello Jijiang,

On Wed, Oct 21, 2015 at 6:46 AM, Jijiang Liu  wrote:

> Add vhost TX checksum and TSO capabilities in virtio-net lib.
>
> Signed-off-by: Jijiang Liu 
> ---
>  drivers/net/virtio/virtio_ethdev.h |5 -
>  1 files changed, 4 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/virtio/virtio_ethdev.h
> b/drivers/net/virtio/virtio_ethdev.h
> index 9026d42..6ee95c6 100644
> --- a/drivers/net/virtio/virtio_ethdev.h
> +++ b/drivers/net/virtio/virtio_ethdev.h
> @@ -64,7 +64,10 @@
>  1u << VIRTIO_NET_F_CTRL_VQ   | \
>  1u << VIRTIO_NET_F_CTRL_RX   | \
>  1u << VIRTIO_NET_F_CTRL_VLAN | \
> -1u << VIRTIO_NET_F_MRG_RXBUF)
> +1u << VIRTIO_NET_F_MRG_RXBUF | \
> +1u << VIRTIO_NET_F_HOST_TSO4 | \
> +1u << VIRTIO_NET_F_HOST_TSO6 | \
> +1u << VIRTIO_NET_F_CSUM)
>
>
You did not update tx offload capabilities field in dev_info.


-- 
David Marchand


[dpdk-dev] [PATCH v4 01/15] eal/arm: atomic operations for ARM

2015-10-29 Thread Jan Viktorin
From: Vlastimil Kosar 

This patch adds architecture specific atomic operation file
for ARM architecture. It utilizes compiler intrinsics only.

Signed-off-by: Vlastimil Kosar 
Signed-off-by: Jan Viktorin 
---
v1 -> v2:
* improve rte_wmb()
* use __atomic_* or __sync_*? (may affect the required GCC version)

v4:
* checkpatch complaints about volatile keyword (but seems to be OK to me)
* checkpatch complaints about do { ... } while (0) for single statement
  with asm volatile (but I didn't find a way how to write it without
  the checkpatch complaints)
* checkpatch is now happy with whitespaces
---
 .../common/include/arch/arm/rte_atomic.h   | 256 +
 1 file changed, 256 insertions(+)
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_atomic.h

diff --git a/lib/librte_eal/common/include/arch/arm/rte_atomic.h 
b/lib/librte_eal/common/include/arch/arm/rte_atomic.h
new file mode 100644
index 000..ea1e485
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/arm/rte_atomic.h
@@ -0,0 +1,256 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2015 RehiveTech. 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 RehiveTech nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_ATOMIC_ARM_H_
+#define _RTE_ATOMIC_ARM_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "generic/rte_atomic.h"
+
+/**
+ * General memory barrier.
+ *
+ * Guarantees that the LOAD and STORE operations generated before the
+ * barrier occur before the LOAD and STORE operations generated after.
+ */
+#definerte_mb()  __sync_synchronize()
+
+/**
+ * Write memory barrier.
+ *
+ * Guarantees that the STORE operations generated before the barrier
+ * occur before the STORE operations generated after.
+ */
+#definerte_wmb() do { asm volatile ("dmb st" : : : "memory"); } while 
(0)
+
+/**
+ * Read memory barrier.
+ *
+ * Guarantees that the LOAD operations generated before the barrier
+ * occur before the LOAD operations generated after.
+ */
+#definerte_rmb() __sync_synchronize()
+
+/*- 16 bit atomic operations 
-*/
+
+#ifndef RTE_FORCE_INTRINSICS
+static inline int
+rte_atomic16_cmpset(volatile uint16_t *dst, uint16_t exp, uint16_t src)
+{
+   return __atomic_compare_exchange(dst, &exp, &src, 0, __ATOMIC_ACQUIRE,
+   __ATOMIC_ACQUIRE) ? 1 : 0;
+}
+
+static inline int rte_atomic16_test_and_set(rte_atomic16_t *v)
+{
+   return rte_atomic16_cmpset((volatile uint16_t *)&v->cnt, 0, 1);
+}
+
+static inline void
+rte_atomic16_inc(rte_atomic16_t *v)
+{
+   __atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE);
+}
+
+static inline void
+rte_atomic16_dec(rte_atomic16_t *v)
+{
+   __atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE);
+}
+
+static inline int rte_atomic16_inc_and_test(rte_atomic16_t *v)
+{
+   return (__atomic_add_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0);
+}
+
+static inline int rte_atomic16_dec_and_test(rte_atomic16_t *v)
+{
+   return (__atomic_sub_fetch(&v->cnt, 1, __ATOMIC_ACQUIRE) == 0);
+}
+
+/*- 32 bit atomic operations 
-*/
+
+static inline int
+rte_atomic32_cmpset(volatile uint32_t *dst, uint32_t exp, uint32_t src)
+{
+   return __atomic_compare_exchange(dst, &exp, &src, 0, __ATOMIC_ACQUIRE,
+   __ATOMIC_ACQUIRE) ? 1 : 0;
+}
+
+static inline int rte_atomic32_test_and_set(rte_atomic32_t *v)
+{
+   return rte_atomic32_cmpset((volatile uint3

[dpdk-dev] [PATCH v4 00/15] Support ARMv7 architecture

2015-10-29 Thread Jan Viktorin
Hello DPDK community,

This is the 4th series of the ARMv7 patchset. I've cleaned up
most checkpatch errors:

* Whitespaces were fixed.

* The asm volatile syntax (checkpatch didn't like the named "%xyz"
  parameters when listed in the InputOperands list as "[xyz]").

* There are still few complaints (documented in each patch) but
  I consider them as unimportant (volatile, couple of line overlaps,
  new typedef). If it still can be done better, please report me
  your ideas.

Other changes:

* The "introduction patch" was moved to be almost the last patch as
  suggested by D. Marchand.

* I've added a note into the release_2_2.rst.

* The RTE_BITMAP_OPTIMIZATIONS was removed.

* The ARMv7 defconfig was renamed as suggested by B. Richardson.

* I've removed the LPM and ACL fixes from the patchset for now.
  The libraries table and pipeline are disabled as well.

* The igb_uio driver is disabled.

* The -Wno-error was restricted to cast-align only.

To be answered (from rte_atomic.h patch):

* use __atomic_* or __sync_*? (may affect the required GCC version)

Regards
Jan

---

You can pull the changes from

  https://github.com/RehiveTech/dpdk.git arm-support-v4

since commit 82fb702077f67585d64a07de0080e5cb6a924a72:

  ixgbe: support new flow director modes for X550 (2015-10-29 00:06:01 +0100)

up to 437c85fd6d9c5f3bdd2411fb9ddf703dc4cba5a5:

  maintainers: claim responsibility for ARMv7 (2015-10-29 13:33:49 +0100)

---

Jan Viktorin (7):
  eal/arm: implement rdtsc by PMU or clock_gettime
  eal/arm: use vector memcpy only when NEON is enabled
  eal/arm: detect arm architecture in cpu flags
  eal/arm: rwlock support for ARM
  eal/arm: add very incomplete rte_vect
  gcc/arm: avoid alignment errors to break build
  maintainers: claim responsibility for ARMv7

Vlastimil Kosar (8):
  eal/arm: atomic operations for ARM
  eal/arm: byte order operations for ARM
  eal/arm: cpu cycle operations for ARM
  eal/arm: prefetch operations for ARM
  eal/arm: spinlock operations for ARM (without HTM)
  eal/arm: vector memcpy for ARM
  eal/arm: cpu flag checks for ARM
  mk: Introduce ARMv7 architecture

 MAINTAINERS|   4 +
 app/test/test_cpuflags.c   |   5 +
 config/defconfig_arm-armv7a-linuxapp-gcc   |  74 +
 doc/guides/rel_notes/release_2_2.rst   |   5 +
 .../common/include/arch/arm/rte_atomic.h   | 256 
 .../common/include/arch/arm/rte_byteorder.h| 150 +
 .../common/include/arch/arm/rte_cpuflags.h | 193 
 .../common/include/arch/arm/rte_cycles.h   | 121 
 .../common/include/arch/arm/rte_memcpy.h   | 334 +
 .../common/include/arch/arm/rte_prefetch.h |  61 
 .../common/include/arch/arm/rte_rwlock.h   |  40 +++
 .../common/include/arch/arm/rte_spinlock.h | 114 +++
 lib/librte_eal/common/include/arch/arm/rte_vect.h  |  84 ++
 mk/arch/arm/rte.vars.mk|  39 +++
 mk/machine/armv7-a/rte.vars.mk |  67 +
 mk/rte.cpuflags.mk |   6 +
 mk/toolchain/gcc/rte.vars.mk   |   6 +
 17 files changed, 1559 insertions(+)
 create mode 100644 config/defconfig_arm-armv7a-linuxapp-gcc
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_atomic.h
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_byteorder.h
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_cpuflags.h
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_cycles.h
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_memcpy.h
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_prefetch.h
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_rwlock.h
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_spinlock.h
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_vect.h
 create mode 100644 mk/arch/arm/rte.vars.mk
 create mode 100644 mk/machine/armv7-a/rte.vars.mk

-- 
2.6.1



[dpdk-dev] [PATCH v4 02/15] eal/arm: byte order operations for ARM

2015-10-29 Thread Jan Viktorin
From: Vlastimil Kosar 

This patch adds architecture specific byte order operations
for ARM. The architecture supports both big and little endian.

Signed-off-by: Vlastimil Kosar 
Signed-off-by: Jan Viktorin 
---
v4: fix passing params to asm volatile for checkpatch
---
 .../common/include/arch/arm/rte_byteorder.h| 150 +
 1 file changed, 150 insertions(+)
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_byteorder.h

diff --git a/lib/librte_eal/common/include/arch/arm/rte_byteorder.h 
b/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
new file mode 100644
index 000..5776997
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/arm/rte_byteorder.h
@@ -0,0 +1,150 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2015 RehiveTech. 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 RehiveTech nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_BYTEORDER_ARM_H_
+#define _RTE_BYTEORDER_ARM_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "generic/rte_byteorder.h"
+
+/*
+ * An architecture-optimized byte swap for a 16-bit value.
+ *
+ * Do not use this function directly. The preferred function is rte_bswap16().
+ */
+static inline uint16_t rte_arch_bswap16(uint16_t _x)
+{
+   register uint16_t x = _x;
+
+   asm volatile ("rev16 %0,%1"
+ : "=r" (x)
+ : "r" (x)
+ );
+   return x;
+}
+
+/*
+ * An architecture-optimized byte swap for a 32-bit value.
+ *
+ * Do not use this function directly. The preferred function is rte_bswap32().
+ */
+static inline uint32_t rte_arch_bswap32(uint32_t _x)
+{
+   register uint32_t x = _x;
+
+   asm volatile ("rev %0,%1"
+ : "=r" (x)
+ : "r" (x)
+ );
+   return x;
+}
+
+/*
+ * An architecture-optimized byte swap for a 64-bit value.
+ *
+  * Do not use this function directly. The preferred function is rte_bswap64().
+ */
+/* 64-bit mode */
+static inline uint64_t rte_arch_bswap64(uint64_t _x)
+{
+   return  __builtin_bswap64(_x);
+}
+
+#ifndef RTE_FORCE_INTRINSICS
+#define rte_bswap16(x) ((uint16_t)(__builtin_constant_p(x) ?   \
+  rte_constant_bswap16(x) :\
+  rte_arch_bswap16(x)))
+
+#define rte_bswap32(x) ((uint32_t)(__builtin_constant_p(x) ?   \
+  rte_constant_bswap32(x) :\
+  rte_arch_bswap32(x)))
+
+#define rte_bswap64(x) ((uint64_t)(__builtin_constant_p(x) ?   \
+  rte_constant_bswap64(x) :\
+  rte_arch_bswap64(x)))
+#else
+/*
+ * __builtin_bswap16 is only available gcc 4.8 and upwards
+ */
+#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)
+#define rte_bswap16(x) ((uint16_t)(__builtin_constant_p(x) ?   \
+  rte_constant_bswap16(x) :\
+  rte_arch_bswap16(x)))
+#endif
+#endif
+
+/* ARM architecture is bi-endian (both big and little). */
+#if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
+
+#define rte_cpu_to_le_16(x) (x)
+#define rte_cpu_to_le_32(x) (x)
+#define rte_cpu_to_le_64(x) (x)
+
+#define rte_cpu_to_be_16(x) rte_bswap16(x)
+#define rte_cpu_to_be_32(x) rte_bswap32(x)
+#define rte_cpu_to_be_64(x) rte_bswap64(x)
+
+#define rte_le_to_cpu_16(x) (x)
+#define

[dpdk-dev] [PATCH v4 03/15] eal/arm: cpu cycle operations for ARM

2015-10-29 Thread Jan Viktorin
From: Vlastimil Kosar 

ARM architecture doesn't have a suitable source of CPU cycles. This
patch uses clock_gettime instead. The implementation should be improved
in the future.

Signed-off-by: Vlastimil Kosar 
Signed-off-by: Jan Viktorin 
---
 .../common/include/arch/arm/rte_cycles.h   | 85 ++
 1 file changed, 85 insertions(+)
 create mode 100644 lib/librte_eal/common/include/arch/arm/rte_cycles.h

diff --git a/lib/librte_eal/common/include/arch/arm/rte_cycles.h 
b/lib/librte_eal/common/include/arch/arm/rte_cycles.h
new file mode 100644
index 000..ff66ae2
--- /dev/null
+++ b/lib/librte_eal/common/include/arch/arm/rte_cycles.h
@@ -0,0 +1,85 @@
+/*
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2015 RehiveTech. 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 RehiveTech nor the names of its
+ *   contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _RTE_CYCLES_ARM_H_
+#define _RTE_CYCLES_ARM_H_
+
+/* ARM v7 does not have suitable source of clock signals. The only clock 
counter
+   available in the core is 32 bit wide. Therefore it is unsuitable as the
+   counter overlaps every few seconds and probably is not accessible by
+   userspace programs. Therefore we use clock_gettime(CLOCK_MONOTONIC_RAW) to
+   simulate counter running at 1GHz.
+*/
+
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "generic/rte_cycles.h"
+
+/**
+ * Read the time base register.
+ *
+ * @return
+ *   The time base for this lcore.
+ */
+static inline uint64_t
+rte_rdtsc(void)
+{
+   struct timespec val;
+   uint64_t v;
+
+   while (clock_gettime(CLOCK_MONOTONIC_RAW, &val) != 0)
+   /* no body */;
+
+   v  = (uint64_t) val.tv_sec * 10LL;
+   v += (uint64_t) val.tv_nsec;
+   return v;
+}
+
+static inline uint64_t
+rte_rdtsc_precise(void)
+{
+   rte_mb();
+   return rte_rdtsc();
+}
+
+static inline uint64_t
+rte_get_tsc_cycles(void) { return rte_rdtsc(); }
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RTE_CYCLES_ARM_H_ */
-- 
2.6.1



  1   2   3   >