[dpdk-dev] [PATCH 0/3] Add MACsec offload support for ixgbe

2016-12-03 Thread Tiwei Bie
This patch set adds the MACsec offload support for ixgbe.
The testpmd is also updated to support MACsec cmds.

Tiwei Bie (3):
  lib: add MACsec offload flags
  net/ixgbe: add MACsec offload support
  app/testpmd: add ixgbe MACsec offload support

 app/test-pmd/cmdline.c  | 389 +
 app/test-pmd/macfwd.c   |   2 +
 app/test-pmd/macswap.c  |   2 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   2 +
 drivers/net/ixgbe/ixgbe_ethdev.c| 436 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  41 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   |  98 +++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 lib/librte_ether/rte_ethdev.h   |   2 +
 lib/librte_mbuf/rte_mbuf.h  |   5 +
 12 files changed, 986 insertions(+), 7 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH 1/3] lib: add MACsec offload flags

2016-12-03 Thread Tiwei Bie
These flags will be used in next commits in the ixgbe pmd.

Signed-off-by: Tiwei Bie 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 lib/librte_mbuf/rte_mbuf.h| 5 +
 2 files changed, 7 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9678179..25a33e9 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -857,6 +857,7 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_TCP_LRO 0x0010
 #define DEV_RX_OFFLOAD_QINQ_STRIP  0x0020
 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x0040
+#define DEV_RX_OFFLOAD_MACSEC_STRIP 0x0080
 
 /**
  * TX offload capabilities of a device.
@@ -874,6 +875,7 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_GRE_TNL_TSO  0x0400/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_IPIP_TNL_TSO 0x0800/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO   0x1000/**< Used for tunneling 
packet. */
+#define DEV_TX_OFFLOAD_MACSEC_INSERT0x2000
 
 /**
  * Ethernet device information
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ead7c6e..46bb23f 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -182,6 +182,11 @@ extern "C" {
 /* add new TX flags here */
 
 /**
+ * MACsec offload flag.
+ */
+#define PKT_TX_MACSEC(1ULL << 44)
+
+/**
  * Bits 45:48 used for the tunnel type.
  * When doing Tx offload like TSO or checksum, the HW needs to configure the
  * tunnel type into the HW descriptors.
-- 
2.7.4



[dpdk-dev] [PATCH 2/3] net/ixgbe: add MACsec offload support

2016-12-03 Thread Tiwei Bie
MACsec (or LinkSec, 802.1AE) is a MAC level encryption/authentication
scheme defined in IEEE 802.1AE that uses symmetric cryptography.
This commit adds the MACsec offload support for ixgbe.

Signed-off-by: Tiwei Bie 
---
 drivers/net/ixgbe/ixgbe_ethdev.c| 436 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  41 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   |  98 +++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 5 files changed, 582 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index edc9b22..2684097 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -232,6 +232,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
+static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev);
 static void ixgbe_dev_interrupt_handler(struct rte_intr_handle *handle,
@@ -744,6 +745,51 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_stats_strings[] = {
 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
   sizeof(rte_ixgbe_stats_strings[0]))
 
+/* MACsec statistics */
+static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
+   {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_untagged)},
+   {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_encrypted)},
+   {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_protected)},
+   {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_octets_encrypted)},
+   {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
+   out_octets_protected)},
+   {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_untagged)},
+   {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_badtag)},
+   {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_nosci)},
+   {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unknownsci)},
+   {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
+   in_octets_decrypted)},
+   {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
+   in_octets_validated)},
+   {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unchecked)},
+   {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_delayed)},
+   {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_late)},
+   {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_ok)},
+   {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_invalid)},
+   {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notvalid)},
+   {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unusedsa)},
+   {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notusingsa)},
+};
+
+#define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
+  sizeof(rte_ixgbe_macsec_strings[0]))
+
 /* Per-queue statistics */
 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
{"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
@@ -2380,6 +2426,8 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
rte_intr_dp_is_en(intr_handle))
ixgbe_dev_rxq_interrupt_setup(dev);
 
+   ixgbe_dev_macsec_interrupt_setup(dev);
+
/* enable uio/vfio intr/eventfd mapping */
rte_intr_enable(intr_handle);
 
@@ -2557,6 +2605,7 @@ ixgbe_dev_close(struct rte_eth_dev *dev)
 static void
 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
   struct ixgbe_hw_stats *hw_stats,
+  struct ixgbe_macsec_stats *macsec_stats,
   uint64_t *total_missed_rx, uint64_t *total_qbrc,
   uint64_t *total_qprc, uint64_t *total_qprdc)
 {
@@ -2726,6 +2775,40 @@ ixgbe_read_stats_registers(struct ixgbe_hw *hw,
/* Flow Director Stats registers */
hw_stats->fdirmatch += IXGBE_READ_REG(

[dpdk-dev] [PATCH 3/3] app/testpmd: add ixgbe MACsec offload support

2016-12-03 Thread Tiwei Bie
add test for set macsec offload
add test for set macsec sc
add test for set macsec sa

Signed-off-by: Tiwei Bie 
---
 app/test-pmd/cmdline.c | 389 +
 app/test-pmd/macfwd.c  |   2 +
 app/test-pmd/macswap.c |   2 +
 app/test-pmd/testpmd.h |   2 +
 app/test-pmd/txonly.c  |   2 +
 5 files changed, 397 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 63b55dc..6d61c88 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -274,6 +274,18 @@ static void cmd_help_long_parsed(void *parsed_result,
 
"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
"Set MAC antispoof for a VF from the PF.\n\n"
+
+   "set macsec offload (port_id) on encrypt (on|off) 
replay-protect (on|off)\n"
+   "Enable MACsec offload.\n\n"
+
+   "set macsec offload (port_id) off\n"
+   "Disable MACsec offload.\n\n"
+
+   "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
+   "Configure MACsec secure connection (SC).\n\n"
+
+   "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) 
(key)\n"
+   "Configure MACsec secure association (SA).\n\n"
 #endif
 
"vlan set strip (on|off) (port_id)\n"
@@ -11409,6 +11421,379 @@ cmdline_parse_inst_t cmd_set_vf_mac_addr = {
NULL,
},
 };
+
+/* MACsec configuration */
+
+/* Common result structure for MACsec offload enable */
+struct cmd_macsec_offload_on_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t macsec;
+   cmdline_fixed_string_t offload;
+   uint8_t port_id;
+   cmdline_fixed_string_t on;
+   cmdline_fixed_string_t encrypt;
+   cmdline_fixed_string_t en_on_off;
+   cmdline_fixed_string_t replay_protect;
+   cmdline_fixed_string_t rp_on_off;
+};
+
+/* Common CLI fields for MACsec offload disable */
+cmdline_parse_token_string_t cmd_macsec_offload_on_set =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+set, "set");
+cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+macsec, "macsec");
+cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+offload, "offload");
+cmdline_parse_token_string_t cmd_macsec_offload_on_port_id =
+   TOKEN_NUM_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+port_id, UINT8);
+cmdline_parse_token_string_t cmd_macsec_offload_on_on =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+on, "on");
+cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+encrypt, "encrypt");
+cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+en_on_off, "on#off");
+cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+replay_protect, "replay-protect");
+cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+rp_on_off, "on#off");
+
+static void
+cmd_set_macsec_offload_on_parsed(
+   void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_macsec_offload_on_result *res = parsed_result;
+   int ret;
+   portid_t port_id = res->port_id;
+   int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
+   int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
+
+   if (port_id_is_invalid(port_id, ENABLED_WARN))
+   return;
+
+   ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
+   ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
+
+   switch (ret) {
+   case 0:
+   break;
+   case -ENODEV:
+   printf("invalid port_id %d\n", port_id);
+   break;
+   default:
+   printf("programming error: (%s)\n", strerror(-ret));
+   }
+}
+
+cmdline_parse_inst_t cmd_set_macsec_offload_on = {
+   .f = cmd_set_macsec_offload_on_parsed,
+   .data = NULL,
+   .help_str 

Re: [dpdk-dev] [PATCH v5 3/8] ethdev: reserve capability flags for PMD-specific API

2017-01-08 Thread Tiwei Bie
On Sun, Jan 08, 2017 at 08:39:55PM +0800, Ananyev, Konstantin wrote:
> Hi Adrien,
> 
> > 
> > Hi Konstantin,
> > 
> > On Thu, Jan 05, 2017 at 11:32:38AM +, Ananyev, Konstantin wrote:
> > > Hi Adrien,
> > >
> > > >
> > > > On Thu, Jan 05, 2017 at 07:56:08AM +0800, Tiwei Bie wrote:
> > > > > On Thu, Jan 05, 2017 at 01:44:18AM +0800, Ananyev, Konstantin wrote:
[...]
> > Well my first reply to this thread was asking why isn't the whole API global
> > from the start then?
> 
> That's good question, and my preference would always be to have the
> API to configure this feature as generic one.
> I guess the main reason why it is not right now we don't reach an agreement
> how this API should look like: 
> http://dpdk.org/ml/archives/dev/2016-September/047810.html
> But I'll leave it to the author to provide the real reason here. 
> 

Yes, currently this work just provided a thin layer over 82599's
hardware MACsec offload support to allow users configure 82599's
MACsec offload engine. The current API may be too specific and may
need a rework to be used with other NICs.

> > 
> > Given there are valid reasons for it not to and no plan to make it so in the
> > near future, applications must be aware that they are including
> > rte_pmd_ixgbe.h to use it. That in itself is a limiting condition, right?
> 
> Yes, it is definitely a limiting factor.
> Though even if API to configure device to use macsec would be PMD specific 
> right now,
> The API to query that capability and the API to use it at datapath 
> (mbuf.ol_flags) still
> can be (and I think should be) device independent and transparent to use.  
> 
> > 
> > > Yes, right now it is supported only by ixgbe PMD, but why that should be 
> > > the
> > > reason to treat is as second-class citizen?
> > > Let say PKT_TX_TUNNEL_* offloads also are supported only by one PMD right 
> > > now.
> > 
> > You are right about PKT_TX_TUNNEL_*, however these flags exist on their own
> > and are not tied to any API function calls, unlike in this series where
> > PKT_TX_MACSEC can only be used if the DEV_TX_OFFLOAD_MACSEC_INSERT
> > capability is present 
> 
> I don't think PKT_TX_TUNNEL_* 'exists on its own'.
> To use it well behaving app have to:
> 1) Query that device does provide that capability: DEV_TX_OFFLOAD_*_TNL_TSO
> 2) configure PMD( & device) to use that capability
> 3) use that offload at run-time TX code (mb->ol_flags |= ...; mb->tx_offload 
> = ...)
> 
> For PKT_TX_TUNNEL_*  2) is pretty simple - user just need to make sure
> that full-featured TX function will be selected:
> txconf.txq_flags = 0; ...;  rte_eth_tx_queue_setup(..., &txconf);
>  
> For TX_MACSEC, as I understand 2) will be more complicated and
> right now is PMD specific, but anyway the main pattern remains the same.
> So at least 1) and 3) could be kept device neutral.
> 

Yes, the PMD-specific APIs focus on the 2nd step:

2) configure PMD( & device) to use that capability

The other parts (querying the capabilities, using the offload
in the datapath, registering the callback, getting the statistics
via xstats) are done in generic way.

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v5 3/8] ethdev: reserve capability flags for PMD-specific API

2017-01-09 Thread Tiwei Bie
On Mon, Jan 09, 2017 at 12:26:53PM +0100, Thomas Monjalon wrote:
> 2017-01-09 11:57, Tiwei Bie:
> > On Sun, Jan 08, 2017 at 08:39:55PM +0800, Ananyev, Konstantin wrote:
> > > > Well my first reply to this thread was asking why isn't the whole API 
> > > > global
> > > > from the start then?
> > > 
> > > That's good question, and my preference would always be to have the
> > > API to configure this feature as generic one.
> > > I guess the main reason why it is not right now we don't reach an 
> > > agreement
> > > how this API should look like: 
> > > http://dpdk.org/ml/archives/dev/2016-September/047810.html
> > > But I'll leave it to the author to provide the real reason here. 
> > 
> > Yes, currently this work just provided a thin layer over 82599's
> > hardware MACsec offload support to allow users configure 82599's
> > MACsec offload engine. The current API may be too specific and may
> > need a rework to be used with other NICs.
> 
> I think it is a really good approach to start such API privately in a driver.
> It will give us more time and experience to design a proper generic API.
> 
> Regarding the mbuf flag, it looks straight-forward, and as it is IEEE
> standardized, I do not see any objection to add it now.
> However, I will wait for the approval of Olivier - as maintainer of mbuf.
> 

I see. Thank you very much for your comments! :-)

Best regards,
Tiwei Bie


[dpdk-dev] [PATCH v6 0/6] Add MACsec offload support for ixgbe

2017-01-10 Thread Tiwei Bie
This patch set adds the MACsec offload support for ixgbe.
The testpmd is also updated to support MACsec cmds.

v2:
- Update the documents for testpmd;
- Update the release notes;
- Reuse the functions provided by base code;

v3:
- Add the missing parts of MACsec mbuf flag and reorganize the patch set;
- Add an ethdev event type for MACsec;
- Advertise the MACsec offload capabilities based on the mac type;
- Minor fixes and improvements;

v4:
- Reserve bits in mbuf and ethdev for PMD specific API;
- Use the reserved bits in PMD specific API;

v5:
- Add MACsec offload in the NIC feature list;
- Minor improvements on comments;

v6:
- Revert the changes related to the reserved flags;
- Rebase the patch set on the latest branch, xstats code is changed recently;
- Update the feature list when adding the MACsec support for ixgbe;

Tiwei Bie (6):
  mbuf: add flag for MACsec
  ethdev: add event type for MACsec
  ethdev: add MACsec offload capability flags
  net/ixgbe: add MACsec offload support
  app/testpmd: add MACsec offload commands
  doc: add ixgbe specific APIs

 app/test-pmd/cmdline.c  | 389 ++
 app/test-pmd/macfwd.c   |   2 +
 app/test-pmd/macswap.c  |   2 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   2 +
 doc/guides/nics/features/default.ini|   1 +
 doc/guides/nics/features/ixgbe.ini  |   1 +
 doc/guides/rel_notes/release_17_02.rst  |  10 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 ++
 drivers/net/ixgbe/ixgbe_ethdev.c| 482 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 100 ++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 lib/librte_ether/rte_ethdev.h   |   3 +
 lib/librte_mbuf/rte_mbuf.c  |   2 +
 lib/librte_mbuf/rte_mbuf.h  |   6 +
 17 files changed, 1088 insertions(+), 5 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH v6 2/6] ethdev: add event type for MACsec

2017-01-10 Thread Tiwei Bie
This commit adds a below event type:

- RTE_ETH_EVENT_MACSEC

This event will occur when the PN counter in a MACsec connection
reaches the exhaustion threshold.

Signed-off-by: Tiwei Bie 
---
 lib/librte_ether/rte_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 1c356c1..d5d2956 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3188,6 +3188,7 @@ enum rte_eth_event_type {
RTE_ETH_EVENT_INTR_RESET,
/**< reset interrupt event, sent to VF on PF reset */
RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
+   RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
RTE_ETH_EVENT_MAX   /**< max value of this enum */
 };
 
-- 
2.7.4



[dpdk-dev] [PATCH v6 1/6] mbuf: add flag for MACsec

2017-01-10 Thread Tiwei Bie
Add a new Tx flag in mbuf, that can be set by applications to
enable the MACsec offload for a packet to be transmitted.

Signed-off-by: Tiwei Bie 
---
 doc/guides/rel_notes/release_17_02.rst | 5 +
 lib/librte_mbuf/rte_mbuf.c | 2 ++
 lib/librte_mbuf/rte_mbuf.h | 6 ++
 3 files changed, 13 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 180af82..3958714 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,11 @@ New Features
   See the :ref:`Generic flow API ` documentation for more
   information.
 
+* **Improved offload support in mbuf.**
+
+  Added a new Tx mbuf flag for MACsec, which can be set by applications
+  to enable the MACsec offload for the packets to be transmitted.
+
 
 Resolved Issues
 ---
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 63f43c8..72ad91e 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -404,6 +404,7 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
case PKT_TX_TUNNEL_GRE: return "PKT_TX_TUNNEL_GRE";
case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
+   case PKT_TX_MACSEC: return "PKT_TX_MACSEC";
default: return NULL;
}
 }
@@ -434,6 +435,7 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t 
buflen)
  "PKT_TX_TUNNEL_NONE" },
{ PKT_TX_TUNNEL_GENEVE, PKT_TX_TUNNEL_MASK,
  "PKT_TX_TUNNEL_NONE" },
+   { PKT_TX_MACSEC, PKT_TX_MACSEC, NULL },
};
const char *name;
unsigned int i;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 4476d75..ffbb4b3 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -182,6 +182,12 @@ extern "C" {
 /* add new TX flags here */
 
 /**
+ * Offload the MACsec. This flag must be set by the application to enable
+ * this offload feature for a packet to be transmitted.
+ */
+#define PKT_TX_MACSEC(1ULL << 44)
+
+/**
  * Bits 45:48 used for the tunnel type.
  * When doing Tx offload like TSO or checksum, the HW needs to configure the
  * tunnel type into the HW descriptors.
-- 
2.7.4



[dpdk-dev] [PATCH v6 3/6] ethdev: add MACsec offload capability flags

2017-01-10 Thread Tiwei Bie
If these flags are advertised by a PMD, the NIC supports the MACsec
offload. The incoming MACsec traffics can be offloaded transparently
after the MACsec offload is configured correctly by the application.
And the application can set the PKT_TX_MACSEC flag in mbufs to enable
the MACsec offload for the packets to be transmitted.

Signed-off-by: Tiwei Bie 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d5d2956..49c073b 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -881,6 +881,7 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_TCP_LRO 0x0010
 #define DEV_RX_OFFLOAD_QINQ_STRIP  0x0020
 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x0040
+#define DEV_RX_OFFLOAD_MACSEC_STRIP 0x0080
 
 /**
  * TX offload capabilities of a device.
@@ -898,6 +899,7 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_GRE_TNL_TSO  0x0400/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_IPIP_TNL_TSO 0x0800/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO   0x1000/**< Used for tunneling 
packet. */
+#define DEV_TX_OFFLOAD_MACSEC_INSERT0x2000
 
 /**
  * Ethernet device information
-- 
2.7.4



[dpdk-dev] [PATCH v6 5/6] app/testpmd: add MACsec offload commands

2017-01-10 Thread Tiwei Bie
Below MACsec offload commands are added:

- set macsec offload  on encrypt on|off replay-protect on|off
- set macsec offload  off
- set macsec sc tx|rx   
- set macsec sa tx|rx 

Also update the testpmd user guide.

Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 app/test-pmd/cmdline.c  | 389 
 app/test-pmd/macfwd.c   |   2 +
 app/test-pmd/macswap.c  |   2 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   2 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 +++
 6 files changed, 429 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f768b6b..4a67894 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -275,6 +275,18 @@ static void cmd_help_long_parsed(void *parsed_result,
 
"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
"Set MAC antispoof for a VF from the PF.\n\n"
+
+   "set macsec offload (port_id) on encrypt (on|off) 
replay-protect (on|off)\n"
+   "Enable MACsec offload.\n\n"
+
+   "set macsec offload (port_id) off\n"
+   "Disable MACsec offload.\n\n"
+
+   "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
+   "Configure MACsec secure connection (SC).\n\n"
+
+   "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) 
(key)\n"
+   "Configure MACsec secure association (SA).\n\n"
 #endif
 
"vlan set strip (on|off) (port_id)\n"
@@ -11488,6 +11500,379 @@ cmdline_parse_inst_t cmd_set_vf_mac_addr = {
NULL,
},
 };
+
+/* MACsec configuration */
+
+/* Common result structure for MACsec offload enable */
+struct cmd_macsec_offload_on_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t macsec;
+   cmdline_fixed_string_t offload;
+   uint8_t port_id;
+   cmdline_fixed_string_t on;
+   cmdline_fixed_string_t encrypt;
+   cmdline_fixed_string_t en_on_off;
+   cmdline_fixed_string_t replay_protect;
+   cmdline_fixed_string_t rp_on_off;
+};
+
+/* Common CLI fields for MACsec offload disable */
+cmdline_parse_token_string_t cmd_macsec_offload_on_set =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+set, "set");
+cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+macsec, "macsec");
+cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+offload, "offload");
+cmdline_parse_token_string_t cmd_macsec_offload_on_port_id =
+   TOKEN_NUM_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+port_id, UINT8);
+cmdline_parse_token_string_t cmd_macsec_offload_on_on =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+on, "on");
+cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+encrypt, "encrypt");
+cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+en_on_off, "on#off");
+cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+replay_protect, "replay-protect");
+cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+rp_on_off, "on#off");
+
+static void
+cmd_set_macsec_offload_on_parsed(
+   void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_macsec_offload_on_result *res = parsed_result;
+   int ret;
+   portid_t port_id = res->port_id;
+   int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
+   int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
+
+   if (port_id_is_invalid(port_id, ENABLED_WARN))
+   return;
+
+   ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
+   ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
+
+   switch (ret) {
+   case 0:
+   break;
+   case -ENODEV:
+   printf(&

[dpdk-dev] [PATCH v6 4/6] net/ixgbe: add MACsec offload support

2017-01-10 Thread Tiwei Bie
MACsec (or LinkSec, 802.1AE) is a MAC level encryption/authentication
scheme defined in IEEE 802.1AE that uses symmetric cryptography.
This commit adds the MACsec offload support for ixgbe.

Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 doc/guides/nics/features/default.ini|   1 +
 doc/guides/nics/features/ixgbe.ini  |   1 +
 drivers/net/ixgbe/ixgbe_ethdev.c| 482 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 100 ++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 7 files changed, 638 insertions(+), 5 deletions(-)

diff --git a/doc/guides/nics/features/default.ini 
b/doc/guides/nics/features/default.ini
index f1bf9bf..c412d6f 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -43,6 +43,7 @@ VLAN offload =
 QinQ offload =
 L3 checksum offload  =
 L4 checksum offload  =
+MACsec offload   =
 Inner L3 checksum=
 Inner L4 checksum=
 Packet type parsing  =
diff --git a/doc/guides/nics/features/ixgbe.ini 
b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..24c02fb 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -36,6 +36,7 @@ VLAN offload = Y
 QinQ offload = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
+MACsec offload   = Y
 Inner L3 checksum= Y
 Inner L4 checksum= Y
 Packet type parsing  = Y
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 060772d..6aad7ef 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -231,6 +231,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
uint16_t reta_size);
 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
+static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
@@ -747,6 +748,51 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_stats_strings[] = {
 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
   sizeof(rte_ixgbe_stats_strings[0]))
 
+/* MACsec statistics */
+static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
+   {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_untagged)},
+   {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_encrypted)},
+   {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_protected)},
+   {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_octets_encrypted)},
+   {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
+   out_octets_protected)},
+   {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_untagged)},
+   {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_badtag)},
+   {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_nosci)},
+   {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unknownsci)},
+   {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
+   in_octets_decrypted)},
+   {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
+   in_octets_validated)},
+   {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unchecked)},
+   {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_delayed)},
+   {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_late)},
+   {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_ok)},
+   {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_invalid)},
+   {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notvalid)},
+   {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unusedsa)},
+   {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notusingsa)},
+};
+
+#define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
+  sizeof(rte_ixgbe_macsec_strings[0]))
+
 /* Per-queue statistics */
 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
{"mbuf_allocation_er

[dpdk-dev] [PATCH v6 6/6] doc: add ixgbe specific APIs

2017-01-10 Thread Tiwei Bie
Add information about the new ixgbe PMD APIs in the release notes.

Signed-off-by: Tiwei Bie 
Acked-by: John McNamara 
---
 doc/guides/rel_notes/release_17_02.rst | 5 +
 1 file changed, 5 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 3958714..a3490a5 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,11 @@ New Features
   See the :ref:`Generic flow API ` documentation for more
   information.
 
+* **Added APIs for MACsec offload support to the ixgbe PMD.**
+
+  Six new APIs have been added to the ixgbe PMD for MACsec offload support.
+  The declarations for the APIs can be found in ``rte_pmd_ixgbe.h``.
+
 * **Improved offload support in mbuf.**
 
   Added a new Tx mbuf flag for MACsec, which can be set by applications
-- 
2.7.4



Re: [dpdk-dev] [PATCH v5 3/8] ethdev: reserve capability flags for PMD-specific API

2017-01-11 Thread Tiwei Bie
On Wed, Jan 11, 2017 at 06:32:48PM +0100, Olivier MATZ wrote:
> Hi Tiwei, Hi Thomas,
> 
> On Mon, 09 Jan 2017 12:26:53 +0100, Thomas Monjalon
>  wrote:
> > 2017-01-09 11:57, Tiwei Bie:
> > > On Sun, Jan 08, 2017 at 08:39:55PM +0800, Ananyev, Konstantin
> > > wrote:  
> > > > > Well my first reply to this thread was asking why isn't the
> > > > > whole API global from the start then?  
> > > > 
> > > > That's good question, and my preference would always be to have
> > > > the API to configure this feature as generic one.
> > > > I guess the main reason why it is not right now we don't reach an
> > > > agreement how this API should look like: 
> > > > http://dpdk.org/ml/archives/dev/2016-September/047810.html
> > > > But I'll leave it to the author to provide the real reason
> > > > here.   
> > > 
> > > Yes, currently this work just provided a thin layer over 82599's
> > > hardware MACsec offload support to allow users configure 82599's
> > > MACsec offload engine. The current API may be too specific and may
> > > need a rework to be used with other NICs.  
> > 
> > I think it is a really good approach to start such API privately in a
> > driver. It will give us more time and experience to design a proper
> > generic API.
> > 
> > Regarding the mbuf flag, it looks straight-forward, and as it is IEEE
> > standardized, I do not see any objection to add it now.
> > However, I will wait for the approval of Olivier - as maintainer of
> > mbuf.
> > 
> 
> Generally speaking, we have to be careful when introducing new mbuf
> flags, since we don't have so much of them (~25 remaining out of 64,
> which mean we may run out of them in 3-4 years).
> 
> In this particular case, despite the flag is added for an ixgbe-specific
> API, when MACsec will be implemented on another PMD, the exact same
> flag would also be needed. That's the same for the ethdev capability
> flag. Moreover, as Thomas stated, it's a standardized protocol so it's
> legitimate to have it included in rte_mbuf.h.
> 
> For me, having PMD-specific APIs for a new feature is not a problem,
> but I think we should try to have a generic API as soon as the feature
> is supported by several PMDs.
> 

Sure! Thank you very much!

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v6 5/6] app/testpmd: add MACsec offload commands

2017-01-13 Thread Tiwei Bie
On Fri, Jan 13, 2017 at 10:07:34AM +0100, Thomas Monjalon wrote:
> There is an error with clang:
> 
> app/test-pmd/cmdline.c:11535:13: fatal error:
> expression which evaluates to zero treated as a null pointer
> constant of type 'const char *' [-Wnon-literal-null-conversion]
>  port_id, UINT8);
>   ^
> 
> Please, send a v7

Oops.. Really sorry about it.. Will send v7!

Best regards,
Tiwei Bie


[dpdk-dev] [PATCH v7 0/6] Add MACsec offload support for ixgbe

2017-01-13 Thread Tiwei Bie
This patch set adds the MACsec offload support for ixgbe.
The testpmd is also updated to support MACsec cmds.

v2:
- Update the documents for testpmd;
- Update the release notes;
- Reuse the functions provided by base code;

v3:
- Add the missing parts of MACsec mbuf flag and reorganize the patch set;
- Add an ethdev event type for MACsec;
- Advertise the MACsec offload capabilities based on the mac type;
- Minor fixes and improvements;

v4:
- Reserve bits in mbuf and ethdev for PMD specific API;
- Use the reserved bits in PMD specific API;

v5:
- Add MACsec offload in the NIC feature list;
- Minor improvements on comments;

v6:
- Revert the changes related to the reserved flags;
- Rebase the patch set on the latest branch, xstats code is changed recently;
- Update the feature list when adding the MACsec support for ixgbe;

v7:
- Fix clang build;

Tiwei Bie (6):
  mbuf: add flag for MACsec
  ethdev: add event type for MACsec
  ethdev: add MACsec offload capability flags
  net/ixgbe: add MACsec offload support
  app/testpmd: add MACsec offload commands
  doc: add ixgbe specific APIs

 app/test-pmd/cmdline.c  | 389 ++
 app/test-pmd/macfwd.c   |   2 +
 app/test-pmd/macswap.c  |   2 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   2 +
 doc/guides/nics/features/default.ini|   1 +
 doc/guides/nics/features/ixgbe.ini  |   1 +
 doc/guides/rel_notes/release_17_02.rst  |  10 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 ++
 drivers/net/ixgbe/ixgbe_ethdev.c| 482 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 100 ++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 lib/librte_ether/rte_ethdev.h   |   3 +
 lib/librte_mbuf/rte_mbuf.c  |   2 +
 lib/librte_mbuf/rte_mbuf.h  |   6 +
 17 files changed, 1088 insertions(+), 5 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH v7 2/6] ethdev: add event type for MACsec

2017-01-13 Thread Tiwei Bie
This commit adds a below event type:

- RTE_ETH_EVENT_MACSEC

This event will occur when the PN counter in a MACsec connection
reaches the exhaustion threshold.

Signed-off-by: Tiwei Bie 
---
 lib/librte_ether/rte_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 1c356c1..d5d2956 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3188,6 +3188,7 @@ enum rte_eth_event_type {
RTE_ETH_EVENT_INTR_RESET,
/**< reset interrupt event, sent to VF on PF reset */
RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
+   RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
RTE_ETH_EVENT_MAX   /**< max value of this enum */
 };
 
-- 
2.7.4



[dpdk-dev] [PATCH v7 1/6] mbuf: add flag for MACsec

2017-01-13 Thread Tiwei Bie
Add a new Tx flag in mbuf, that can be set by applications to
enable the MACsec offload for a packet to be transmitted.

Signed-off-by: Tiwei Bie 
Acked-by: Olivier Matz 
---
 doc/guides/rel_notes/release_17_02.rst | 5 +
 lib/librte_mbuf/rte_mbuf.c | 2 ++
 lib/librte_mbuf/rte_mbuf.h | 6 ++
 3 files changed, 13 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 180af82..3958714 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,11 @@ New Features
   See the :ref:`Generic flow API ` documentation for more
   information.
 
+* **Improved offload support in mbuf.**
+
+  Added a new Tx mbuf flag for MACsec, which can be set by applications
+  to enable the MACsec offload for the packets to be transmitted.
+
 
 Resolved Issues
 ---
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 63f43c8..72ad91e 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -404,6 +404,7 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
case PKT_TX_TUNNEL_GRE: return "PKT_TX_TUNNEL_GRE";
case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
+   case PKT_TX_MACSEC: return "PKT_TX_MACSEC";
default: return NULL;
}
 }
@@ -434,6 +435,7 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t 
buflen)
  "PKT_TX_TUNNEL_NONE" },
{ PKT_TX_TUNNEL_GENEVE, PKT_TX_TUNNEL_MASK,
  "PKT_TX_TUNNEL_NONE" },
+   { PKT_TX_MACSEC, PKT_TX_MACSEC, NULL },
};
const char *name;
unsigned int i;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 4476d75..ffbb4b3 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -182,6 +182,12 @@ extern "C" {
 /* add new TX flags here */
 
 /**
+ * Offload the MACsec. This flag must be set by the application to enable
+ * this offload feature for a packet to be transmitted.
+ */
+#define PKT_TX_MACSEC(1ULL << 44)
+
+/**
  * Bits 45:48 used for the tunnel type.
  * When doing Tx offload like TSO or checksum, the HW needs to configure the
  * tunnel type into the HW descriptors.
-- 
2.7.4



[dpdk-dev] [PATCH v7 2/6] ethdev: add event type for MACsec

2017-01-13 Thread Tiwei Bie
This commit adds a below event type:

- RTE_ETH_EVENT_MACSEC

This event will occur when the PN counter in a MACsec connection
reaches the exhaustion threshold.

Signed-off-by: Tiwei Bie 
---
 lib/librte_ether/rte_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 1c356c1..d5d2956 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3188,6 +3188,7 @@ enum rte_eth_event_type {
RTE_ETH_EVENT_INTR_RESET,
/**< reset interrupt event, sent to VF on PF reset */
RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
+   RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
RTE_ETH_EVENT_MAX   /**< max value of this enum */
 };
 
-- 
2.7.4



[dpdk-dev] [PATCH v7 3/6] ethdev: add MACsec offload capability flags

2017-01-13 Thread Tiwei Bie
If these flags are advertised by a PMD, the NIC supports the MACsec
offload. The incoming MACsec traffics can be offloaded transparently
after the MACsec offload is configured correctly by the application.
And the application can set the PKT_TX_MACSEC flag in mbufs to enable
the MACsec offload for the packets to be transmitted.

Signed-off-by: Tiwei Bie 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d5d2956..49c073b 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -881,6 +881,7 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_TCP_LRO 0x0010
 #define DEV_RX_OFFLOAD_QINQ_STRIP  0x0020
 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x0040
+#define DEV_RX_OFFLOAD_MACSEC_STRIP 0x0080
 
 /**
  * TX offload capabilities of a device.
@@ -898,6 +899,7 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_GRE_TNL_TSO  0x0400/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_IPIP_TNL_TSO 0x0800/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO   0x1000/**< Used for tunneling 
packet. */
+#define DEV_TX_OFFLOAD_MACSEC_INSERT0x2000
 
 /**
  * Ethernet device information
-- 
2.7.4



[dpdk-dev] [PATCH v7 0/6] Add MACsec offload support for ixgbe

2017-01-13 Thread Tiwei Bie
This patch set adds the MACsec offload support for ixgbe.
The testpmd is also updated to support MACsec cmds.

v2:
- Update the documents for testpmd;
- Update the release notes;
- Reuse the functions provided by base code;

v3:
- Add the missing parts of MACsec mbuf flag and reorganize the patch set;
- Add an ethdev event type for MACsec;
- Advertise the MACsec offload capabilities based on the mac type;
- Minor fixes and improvements;

v4:
- Reserve bits in mbuf and ethdev for PMD specific API;
- Use the reserved bits in PMD specific API;

v5:
- Add MACsec offload in the NIC feature list;
- Minor improvements on comments;

v6:
- Revert the changes related to the reserved flags;
- Rebase the patch set on the latest branch, xstats code is changed recently;
- Update the feature list when adding the MACsec support for ixgbe;

v7:
- Fix clang build;

Tiwei Bie (6):
  mbuf: add flag for MACsec
  ethdev: add event type for MACsec
  ethdev: add MACsec offload capability flags
  net/ixgbe: add MACsec offload support
  app/testpmd: add MACsec offload commands
  doc: add ixgbe specific APIs

 app/test-pmd/cmdline.c  | 389 ++
 app/test-pmd/macfwd.c   |   2 +
 app/test-pmd/macswap.c  |   2 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   2 +
 doc/guides/nics/features/default.ini|   1 +
 doc/guides/nics/features/ixgbe.ini  |   1 +
 doc/guides/rel_notes/release_17_02.rst  |  10 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 ++
 drivers/net/ixgbe/ixgbe_ethdev.c| 482 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 100 ++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 lib/librte_ether/rte_ethdev.h   |   3 +
 lib/librte_mbuf/rte_mbuf.c  |   2 +
 lib/librte_mbuf/rte_mbuf.h  |   6 +
 17 files changed, 1088 insertions(+), 5 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH v7 1/6] mbuf: add flag for MACsec

2017-01-13 Thread Tiwei Bie
Add a new Tx flag in mbuf, that can be set by applications to
enable the MACsec offload for a packet to be transmitted.

Signed-off-by: Tiwei Bie 
Acked-by: Olivier Matz 
---
 doc/guides/rel_notes/release_17_02.rst | 5 +
 lib/librte_mbuf/rte_mbuf.c | 2 ++
 lib/librte_mbuf/rte_mbuf.h | 6 ++
 3 files changed, 13 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 180af82..3958714 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,11 @@ New Features
   See the :ref:`Generic flow API ` documentation for more
   information.
 
+* **Improved offload support in mbuf.**
+
+  Added a new Tx mbuf flag for MACsec, which can be set by applications
+  to enable the MACsec offload for the packets to be transmitted.
+
 
 Resolved Issues
 ---
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 63f43c8..72ad91e 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -404,6 +404,7 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
case PKT_TX_TUNNEL_GRE: return "PKT_TX_TUNNEL_GRE";
case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
+   case PKT_TX_MACSEC: return "PKT_TX_MACSEC";
default: return NULL;
}
 }
@@ -434,6 +435,7 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t 
buflen)
  "PKT_TX_TUNNEL_NONE" },
{ PKT_TX_TUNNEL_GENEVE, PKT_TX_TUNNEL_MASK,
  "PKT_TX_TUNNEL_NONE" },
+   { PKT_TX_MACSEC, PKT_TX_MACSEC, NULL },
};
const char *name;
unsigned int i;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index 4476d75..ffbb4b3 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -182,6 +182,12 @@ extern "C" {
 /* add new TX flags here */
 
 /**
+ * Offload the MACsec. This flag must be set by the application to enable
+ * this offload feature for a packet to be transmitted.
+ */
+#define PKT_TX_MACSEC(1ULL << 44)
+
+/**
  * Bits 45:48 used for the tunnel type.
  * When doing Tx offload like TSO or checksum, the HW needs to configure the
  * tunnel type into the HW descriptors.
-- 
2.7.4



[dpdk-dev] [PATCH v7 6/6] doc: add ixgbe specific APIs

2017-01-13 Thread Tiwei Bie
Add information about the new ixgbe PMD APIs in the release notes.

Signed-off-by: Tiwei Bie 
Acked-by: John McNamara 
---
 doc/guides/rel_notes/release_17_02.rst | 5 +
 1 file changed, 5 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 3958714..a3490a5 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,11 @@ New Features
   See the :ref:`Generic flow API ` documentation for more
   information.
 
+* **Added APIs for MACsec offload support to the ixgbe PMD.**
+
+  Six new APIs have been added to the ixgbe PMD for MACsec offload support.
+  The declarations for the APIs can be found in ``rte_pmd_ixgbe.h``.
+
 * **Improved offload support in mbuf.**
 
   Added a new Tx mbuf flag for MACsec, which can be set by applications
-- 
2.7.4



[dpdk-dev] [PATCH v7 4/6] net/ixgbe: add MACsec offload support

2017-01-13 Thread Tiwei Bie
MACsec (or LinkSec, 802.1AE) is a MAC level encryption/authentication
scheme defined in IEEE 802.1AE that uses symmetric cryptography.
This commit adds the MACsec offload support for ixgbe.

Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 doc/guides/nics/features/default.ini|   1 +
 doc/guides/nics/features/ixgbe.ini  |   1 +
 drivers/net/ixgbe/ixgbe_ethdev.c| 482 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 100 ++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 7 files changed, 638 insertions(+), 5 deletions(-)

diff --git a/doc/guides/nics/features/default.ini 
b/doc/guides/nics/features/default.ini
index f1bf9bf..c412d6f 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -43,6 +43,7 @@ VLAN offload =
 QinQ offload =
 L3 checksum offload  =
 L4 checksum offload  =
+MACsec offload   =
 Inner L3 checksum=
 Inner L4 checksum=
 Packet type parsing  =
diff --git a/doc/guides/nics/features/ixgbe.ini 
b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..24c02fb 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -36,6 +36,7 @@ VLAN offload = Y
 QinQ offload = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
+MACsec offload   = Y
 Inner L3 checksum= Y
 Inner L4 checksum= Y
 Packet type parsing  = Y
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index b7415e8..08f4449 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -231,6 +231,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
uint16_t reta_size);
 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
+static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
@@ -747,6 +748,51 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_stats_strings[] = {
 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
   sizeof(rte_ixgbe_stats_strings[0]))
 
+/* MACsec statistics */
+static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
+   {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_untagged)},
+   {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_encrypted)},
+   {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_protected)},
+   {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_octets_encrypted)},
+   {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
+   out_octets_protected)},
+   {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_untagged)},
+   {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_badtag)},
+   {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_nosci)},
+   {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unknownsci)},
+   {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
+   in_octets_decrypted)},
+   {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
+   in_octets_validated)},
+   {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unchecked)},
+   {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_delayed)},
+   {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_late)},
+   {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_ok)},
+   {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_invalid)},
+   {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notvalid)},
+   {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unusedsa)},
+   {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notusingsa)},
+};
+
+#define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
+  sizeof(rte_ixgbe_macsec_strings[0]))
+
 /* Per-queue statistics */
 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
{"mbuf_allocation_er

[dpdk-dev] [PATCH v7 5/6] app/testpmd: add MACsec offload commands

2017-01-13 Thread Tiwei Bie
Below MACsec offload commands are added:

- set macsec offload  on encrypt on|off replay-protect on|off
- set macsec offload  off
- set macsec sc tx|rx   
- set macsec sa tx|rx 

Also update the testpmd user guide.

Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 app/test-pmd/cmdline.c  | 389 
 app/test-pmd/macfwd.c   |   2 +
 app/test-pmd/macswap.c  |   2 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   2 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 +++
 6 files changed, 429 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f768b6b..1bf42ba 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -275,6 +275,18 @@ static void cmd_help_long_parsed(void *parsed_result,
 
"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
"Set MAC antispoof for a VF from the PF.\n\n"
+
+   "set macsec offload (port_id) on encrypt (on|off) 
replay-protect (on|off)\n"
+   "Enable MACsec offload.\n\n"
+
+   "set macsec offload (port_id) off\n"
+   "Disable MACsec offload.\n\n"
+
+   "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
+   "Configure MACsec secure connection (SC).\n\n"
+
+   "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) 
(key)\n"
+   "Configure MACsec secure association (SA).\n\n"
 #endif
 
"vlan set strip (on|off) (port_id)\n"
@@ -11488,6 +11500,379 @@ cmdline_parse_inst_t cmd_set_vf_mac_addr = {
NULL,
},
 };
+
+/* MACsec configuration */
+
+/* Common result structure for MACsec offload enable */
+struct cmd_macsec_offload_on_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t macsec;
+   cmdline_fixed_string_t offload;
+   uint8_t port_id;
+   cmdline_fixed_string_t on;
+   cmdline_fixed_string_t encrypt;
+   cmdline_fixed_string_t en_on_off;
+   cmdline_fixed_string_t replay_protect;
+   cmdline_fixed_string_t rp_on_off;
+};
+
+/* Common CLI fields for MACsec offload disable */
+cmdline_parse_token_string_t cmd_macsec_offload_on_set =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+set, "set");
+cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+macsec, "macsec");
+cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+offload, "offload");
+cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
+   TOKEN_NUM_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+port_id, UINT8);
+cmdline_parse_token_string_t cmd_macsec_offload_on_on =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+on, "on");
+cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+encrypt, "encrypt");
+cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+en_on_off, "on#off");
+cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+replay_protect, "replay-protect");
+cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+rp_on_off, "on#off");
+
+static void
+cmd_set_macsec_offload_on_parsed(
+   void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_macsec_offload_on_result *res = parsed_result;
+   int ret;
+   portid_t port_id = res->port_id;
+   int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
+   int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
+
+   if (port_id_is_invalid(port_id, ENABLED_WARN))
+   return;
+
+   ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
+   ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
+
+   switch (ret) {
+   case 0:
+   break;
+   case -ENODEV:
+   printf(&

[dpdk-dev] [PATCH v7 3/6] ethdev: add MACsec offload capability flags

2017-01-13 Thread Tiwei Bie
If these flags are advertised by a PMD, the NIC supports the MACsec
offload. The incoming MACsec traffics can be offloaded transparently
after the MACsec offload is configured correctly by the application.
And the application can set the PKT_TX_MACSEC flag in mbufs to enable
the MACsec offload for the packets to be transmitted.

Signed-off-by: Tiwei Bie 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d5d2956..49c073b 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -881,6 +881,7 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_TCP_LRO 0x0010
 #define DEV_RX_OFFLOAD_QINQ_STRIP  0x0020
 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x0040
+#define DEV_RX_OFFLOAD_MACSEC_STRIP 0x0080
 
 /**
  * TX offload capabilities of a device.
@@ -898,6 +899,7 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_GRE_TNL_TSO  0x0400/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_IPIP_TNL_TSO 0x0800/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO   0x1000/**< Used for tunneling 
packet. */
+#define DEV_TX_OFFLOAD_MACSEC_INSERT0x2000
 
 /**
  * Ethernet device information
-- 
2.7.4



[dpdk-dev] [PATCH v7 6/6] doc: add ixgbe specific APIs

2017-01-13 Thread Tiwei Bie
Add information about the new ixgbe PMD APIs in the release notes.

Signed-off-by: Tiwei Bie 
Acked-by: John McNamara 
---
 doc/guides/rel_notes/release_17_02.rst | 5 +
 1 file changed, 5 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 3958714..a3490a5 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,11 @@ New Features
   See the :ref:`Generic flow API ` documentation for more
   information.
 
+* **Added APIs for MACsec offload support to the ixgbe PMD.**
+
+  Six new APIs have been added to the ixgbe PMD for MACsec offload support.
+  The declarations for the APIs can be found in ``rte_pmd_ixgbe.h``.
+
 * **Improved offload support in mbuf.**
 
   Added a new Tx mbuf flag for MACsec, which can be set by applications
-- 
2.7.4



[dpdk-dev] [PATCH v7 5/6] app/testpmd: add MACsec offload commands

2017-01-13 Thread Tiwei Bie
Below MACsec offload commands are added:

- set macsec offload  on encrypt on|off replay-protect on|off
- set macsec offload  off
- set macsec sc tx|rx   
- set macsec sa tx|rx 

Also update the testpmd user guide.

Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 app/test-pmd/cmdline.c  | 389 
 app/test-pmd/macfwd.c   |   2 +
 app/test-pmd/macswap.c  |   2 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   2 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 +++
 6 files changed, 429 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f768b6b..1bf42ba 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -275,6 +275,18 @@ static void cmd_help_long_parsed(void *parsed_result,
 
"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
"Set MAC antispoof for a VF from the PF.\n\n"
+
+   "set macsec offload (port_id) on encrypt (on|off) 
replay-protect (on|off)\n"
+   "Enable MACsec offload.\n\n"
+
+   "set macsec offload (port_id) off\n"
+   "Disable MACsec offload.\n\n"
+
+   "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
+   "Configure MACsec secure connection (SC).\n\n"
+
+   "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) 
(key)\n"
+   "Configure MACsec secure association (SA).\n\n"
 #endif
 
"vlan set strip (on|off) (port_id)\n"
@@ -11488,6 +11500,379 @@ cmdline_parse_inst_t cmd_set_vf_mac_addr = {
NULL,
},
 };
+
+/* MACsec configuration */
+
+/* Common result structure for MACsec offload enable */
+struct cmd_macsec_offload_on_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t macsec;
+   cmdline_fixed_string_t offload;
+   uint8_t port_id;
+   cmdline_fixed_string_t on;
+   cmdline_fixed_string_t encrypt;
+   cmdline_fixed_string_t en_on_off;
+   cmdline_fixed_string_t replay_protect;
+   cmdline_fixed_string_t rp_on_off;
+};
+
+/* Common CLI fields for MACsec offload disable */
+cmdline_parse_token_string_t cmd_macsec_offload_on_set =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+set, "set");
+cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+macsec, "macsec");
+cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+offload, "offload");
+cmdline_parse_token_num_t cmd_macsec_offload_on_port_id =
+   TOKEN_NUM_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+port_id, UINT8);
+cmdline_parse_token_string_t cmd_macsec_offload_on_on =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+on, "on");
+cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+encrypt, "encrypt");
+cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+en_on_off, "on#off");
+cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+replay_protect, "replay-protect");
+cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+rp_on_off, "on#off");
+
+static void
+cmd_set_macsec_offload_on_parsed(
+   void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_macsec_offload_on_result *res = parsed_result;
+   int ret;
+   portid_t port_id = res->port_id;
+   int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
+   int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
+
+   if (port_id_is_invalid(port_id, ENABLED_WARN))
+   return;
+
+   ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
+   ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
+
+   switch (ret) {
+   case 0:
+   break;
+   case -ENODEV:
+   printf(&

[dpdk-dev] [PATCH v7 4/6] net/ixgbe: add MACsec offload support

2017-01-13 Thread Tiwei Bie
MACsec (or LinkSec, 802.1AE) is a MAC level encryption/authentication
scheme defined in IEEE 802.1AE that uses symmetric cryptography.
This commit adds the MACsec offload support for ixgbe.

Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 doc/guides/nics/features/default.ini|   1 +
 doc/guides/nics/features/ixgbe.ini  |   1 +
 drivers/net/ixgbe/ixgbe_ethdev.c| 482 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 100 ++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 7 files changed, 638 insertions(+), 5 deletions(-)

diff --git a/doc/guides/nics/features/default.ini 
b/doc/guides/nics/features/default.ini
index f1bf9bf..c412d6f 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -43,6 +43,7 @@ VLAN offload =
 QinQ offload =
 L3 checksum offload  =
 L4 checksum offload  =
+MACsec offload   =
 Inner L3 checksum=
 Inner L4 checksum=
 Packet type parsing  =
diff --git a/doc/guides/nics/features/ixgbe.ini 
b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..24c02fb 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -36,6 +36,7 @@ VLAN offload = Y
 QinQ offload = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
+MACsec offload   = Y
 Inner L3 checksum= Y
 Inner L4 checksum= Y
 Packet type parsing  = Y
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index b7415e8..08f4449 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -231,6 +231,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
uint16_t reta_size);
 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
+static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
@@ -747,6 +748,51 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_stats_strings[] = {
 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
   sizeof(rte_ixgbe_stats_strings[0]))
 
+/* MACsec statistics */
+static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
+   {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_untagged)},
+   {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_encrypted)},
+   {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_protected)},
+   {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_octets_encrypted)},
+   {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
+   out_octets_protected)},
+   {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_untagged)},
+   {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_badtag)},
+   {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_nosci)},
+   {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unknownsci)},
+   {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
+   in_octets_decrypted)},
+   {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
+   in_octets_validated)},
+   {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unchecked)},
+   {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_delayed)},
+   {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_late)},
+   {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_ok)},
+   {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_invalid)},
+   {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notvalid)},
+   {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unusedsa)},
+   {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notusingsa)},
+};
+
+#define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
+  sizeof(rte_ixgbe_macsec_strings[0]))
+
 /* Per-queue statistics */
 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
{"mbuf_allocation_er

[dpdk-dev] [PATCH v1] fix API parameter checking for ixgbe

2017-01-24 Thread Tiwei Bie
When MACsec patch was merged. The helper function is_ixgbe_pmd() was
just raised and merged in another git tree. Now, both of them have
been merged in the same git tree. So do the same fix for MACsec.

Tiwei Bie (1):
  net/ixgbe: fix API parameter checking

 drivers/net/ixgbe/ixgbe_ethdev.c  | 30 ++
 drivers/net/ixgbe/rte_pmd_ixgbe.h |  4 
 2 files changed, 34 insertions(+)

-- 
2.7.4



[dpdk-dev] [PATCH v1] net/ixgbe: fix API parameter checking

2017-01-24 Thread Tiwei Bie
Add checks to rte_pmd_ixgbe_macsec_* APIs to ensure that the
port is an ixgbe port.

Fixes: b35d309710fe ("net/ixgbe: add MACsec offload")

Signed-off-by: Tiwei Bie 
---
 drivers/net/ixgbe/ixgbe_ethdev.c  | 30 ++
 drivers/net/ixgbe/rte_pmd_ixgbe.h |  4 
 2 files changed, 34 insertions(+)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ad63e5a..58a4a2e 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -8222,10 +8222,15 @@ rte_pmd_ixgbe_macsec_enable(uint8_t port, uint8_t en, 
uint8_t rp)
 {
struct ixgbe_hw *hw;
struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
uint32_t ctrl;
 
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+   return -ENOTSUP;
+
dev = &rte_eth_devices[port];
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -8301,10 +8306,15 @@ rte_pmd_ixgbe_macsec_disable(uint8_t port)
 {
struct ixgbe_hw *hw;
struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
uint32_t ctrl;
 
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+   return -ENOTSUP;
+
dev = &rte_eth_devices[port];
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -8361,10 +8371,15 @@ rte_pmd_ixgbe_macsec_config_txsc(uint8_t port, uint8_t 
*mac)
 {
struct ixgbe_hw *hw;
struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
uint32_t ctrl;
 
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+   return -ENOTSUP;
+
dev = &rte_eth_devices[port];
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -8382,10 +8397,15 @@ rte_pmd_ixgbe_macsec_config_rxsc(uint8_t port, uint8_t 
*mac, uint16_t pi)
 {
struct ixgbe_hw *hw;
struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
uint32_t ctrl;
 
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+   return -ENOTSUP;
+
dev = &rte_eth_devices[port];
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -8405,10 +8425,15 @@ rte_pmd_ixgbe_macsec_select_txsa(uint8_t port, uint8_t 
idx, uint8_t an,
 {
struct ixgbe_hw *hw;
struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
uint32_t ctrl, i;
 
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+   return -ENOTSUP;
+
dev = &rte_eth_devices[port];
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
@@ -8457,10 +8482,15 @@ rte_pmd_ixgbe_macsec_select_rxsa(uint8_t port, uint8_t 
idx, uint8_t an,
 {
struct ixgbe_hw *hw;
struct rte_eth_dev *dev;
+   struct rte_eth_dev_info dev_info;
uint32_t ctrl, i;
 
RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
 
+   rte_eth_dev_info_get(port, &dev_info);
+   if (is_ixgbe_pmd(dev_info.driver_name) != 0)
+   return -ENOTSUP;
+
dev = &rte_eth_devices[port];
hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
 
diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.h 
b/drivers/net/ixgbe/rte_pmd_ixgbe.h
index dade57a..d4efe07 100644
--- a/drivers/net/ixgbe/rte_pmd_ixgbe.h
+++ b/drivers/net/ixgbe/rte_pmd_ixgbe.h
@@ -222,6 +222,7 @@ int rte_pmd_ixgbe_macsec_disable(uint8_t port);
  * @return
  *   - (0) if successful.
  *   - (-ENODEV) if *port* invalid.
+ *   - (-ENOTSUP) if hardware doesn't support this feature.
  */
 int rte_pmd_ixgbe_macsec_config_txsc(uint8_t port, uint8_t *mac);
 
@@ -237,6 +238,7 @@ int rte_pmd_ixgbe_macsec_config_txsc(uint8_t port, uint8_t 
*mac);
  * @return
  *   - (0) if successful.
  *   - (-ENODEV) if *port* invalid.
+ *   - (-ENOTSUP) if hardware doesn't support this feature.
  */
 int rte_pmd_ixgbe_macsec_config_rxsc(uint8_t port, uint8_t *mac, uint16_t pi);
 
@@ -256,6 +258,7 @@ int rte_pmd_ixgbe_macsec_config_rxsc(uint8_t port, uint8_t 
*mac, uint16_t pi);
  * @return
  *   - (0) if successful.
  *   - (-ENODEV) if *port* invalid.
+ *   - (-ENOTSUP) if hardware doesn't support this feature.
  *   - (-EINVAL) if bad parameter.
  */
 int rte_pmd_ixgbe_macsec_select_txsa(uint8_t port, uint8_t idx, uint8_t an,
@@ -277,6 +280,7 @@ int rte_pmd_ixgbe_macsec_select_txsa(uint8_t port, uint8_t 
idx, uint8_t an,
  * @return
  *   - (0) if

Re: [dpdk-dev] [PATCH] net/ixgbe: clean up rte_eth_dev_info_get

2017-01-24 Thread Tiwei Bie
On Wed, Jan 25, 2017 at 10:39:22AM +0800, Wenzhuo Lu wrote:
> It'not appropriate to call rte_eth_dev_info_get in PMD,
> as rte_eth_dev_info_get need to get info from PMD.
> Remove rte_eth_dev_info_get from PMD code and get the
> info directly.
> 
> Signed-off-by: Wenzhuo Lu 
> ---
>  drivers/net/ixgbe/ixgbe_ethdev.c | 144 
> ++-
>  1 file changed, 68 insertions(+), 76 deletions(-)
> 
> diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c 
> b/drivers/net/ixgbe/ixgbe_ethdev.c
> index 64ce55a..f14a68b 100644
> --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> @@ -4401,17 +4401,17 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused 
> struct rte_eth_dev *dev,
>   int rar_entry;
>   uint8_t *new_mac = (uint8_t *)(mac_addr);
>   struct rte_eth_dev *dev;
> - struct rte_eth_dev_info dev_info;
> + struct rte_pci_device *pci_dev;
>  
>   RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
>  
>   dev = &rte_eth_devices[port];
> - rte_eth_dev_info_get(port, &dev_info);
> + pci_dev = IXGBE_DEV_TO_PCI(dev);
>  
> - if (is_ixgbe_pmd(dev_info.driver_name) != 0)
> + if (is_ixgbe_pmd(dev->data->drv_name))
>   return -ENOTSUP;
>  

The return value of is_ixgbe_pmd() is not boolean (actually I think it
should be based on its name). If we omit the comparison with 0, the code
looks weird. It looks like it'll return -ENOTSUP if the port's driver
is ixgbe PMD.

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH] net/ixgbe: clean up rte_eth_dev_info_get

2017-01-24 Thread Tiwei Bie
On Wed, Jan 25, 2017 at 01:13:32PM +0800, Lu, Wenzhuo wrote:
> Hi Tiwei,
> 
> > -Original Message-
> > From: Bie, Tiwei
> > Sent: Wednesday, January 25, 2017 11:17 AM
> > To: Lu, Wenzhuo
> > Cc: dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH] net/ixgbe: clean up rte_eth_dev_info_get
> > 
> > On Wed, Jan 25, 2017 at 10:39:22AM +0800, Wenzhuo Lu wrote:
> > > It'not appropriate to call rte_eth_dev_info_get in PMD, as
> > > rte_eth_dev_info_get need to get info from PMD.
> > > Remove rte_eth_dev_info_get from PMD code and get the info directly.
> > >
> > > Signed-off-by: Wenzhuo Lu 
> > > ---
> > >  drivers/net/ixgbe/ixgbe_ethdev.c | 144
> > > ++-
> > >  1 file changed, 68 insertions(+), 76 deletions(-)
> > >
> > > diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c
> > > b/drivers/net/ixgbe/ixgbe_ethdev.c
> > > index 64ce55a..f14a68b 100644
> > > --- a/drivers/net/ixgbe/ixgbe_ethdev.c
> > > +++ b/drivers/net/ixgbe/ixgbe_ethdev.c
> > > @@ -4401,17 +4401,17 @@ static int
> > ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
> > >   int rar_entry;
> > >   uint8_t *new_mac = (uint8_t *)(mac_addr);
> > >   struct rte_eth_dev *dev;
> > > - struct rte_eth_dev_info dev_info;
> > > + struct rte_pci_device *pci_dev;
> > >
> > >   RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
> > >
> > >   dev = &rte_eth_devices[port];
> > > - rte_eth_dev_info_get(port, &dev_info);
> > > + pci_dev = IXGBE_DEV_TO_PCI(dev);
> > >
> > > - if (is_ixgbe_pmd(dev_info.driver_name) != 0)
> > > + if (is_ixgbe_pmd(dev->data->drv_name))
> > >   return -ENOTSUP;
> > >
> > 
> > The return value of is_ixgbe_pmd() is not boolean (actually I think it 
> > should be
> > based on its name). If we omit the comparison with 0, the code looks weird. 
> > It
> > looks like it'll return -ENOTSUP if the port's driver is ixgbe PMD.
> 
> Yes, it’s weird. But what makes it weird is not the missing comparison but 
> the function name.
> Better changing it to ixgbe_pmd_check. How about it?
> 

Yeah, I also prefer to change the helper function itself. But I'm not
good at the naming. I'd like to hear others' opinion. :-)

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up rte_eth_dev_info_get

2017-02-05 Thread Tiwei Bie
On Mon, Feb 06, 2017 at 10:09:32AM +0800, Wenzhuo Lu wrote:
[...]
>  static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct ixgbe_dcb_config 
> *dcb_config);
> -static int is_ixgbe_pmd(const char *driver_name);
> +static int is_device_supported(struct rte_eth_dev *dev, struct eth_driver 
> *drv);
>  

Should be:
static bool is_device_supported(struct rte_eth_dev *dev, struct eth_driver 
*drv);

>  /* For Virtual Function support */
>  static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev);
> @@ -4380,16 +4380,14 @@ static int ixgbevf_dev_xstats_get_names(__rte_unused 
> struct rte_eth_dev *dev,
>   ixgbe_add_rar(dev, addr, 0, 0);
>  }
>  
> -static int
> -is_ixgbe_pmd(const char *driver_name)
> +static bool
> +is_device_supported(struct rte_eth_dev *dev, struct eth_driver *drv)
>  {
> - if (!strstr(driver_name, "ixgbe"))
> - return -ENOTSUP;
> + if (strcmp(dev->driver->pci_drv.driver.name,
> +drv->pci_drv.driver.name))
> + return FALSE;
>  

It would be better to use `false' instead of `FALSE'.

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up rte_eth_dev_info_get

2017-02-05 Thread Tiwei Bie
On Mon, Feb 06, 2017 at 10:41:28AM +0800, Lu, Wenzhuo wrote:
> Hi Tiwei,
> 
> > -Original Message-
> > From: Bie, Tiwei
> > Sent: Monday, February 6, 2017 10:31 AM
> > To: Lu, Wenzhuo
> > Cc: dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up rte_eth_dev_info_get
> > 
> > On Mon, Feb 06, 2017 at 10:09:32AM +0800, Wenzhuo Lu wrote:
> > [...]
> > >  static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct
> > > ixgbe_dcb_config *dcb_config); -static int is_ixgbe_pmd(const char
> > > *driver_name);
> > > +static int is_device_supported(struct rte_eth_dev *dev, struct
> > > +eth_driver *drv);
> > >
> > 
> > Should be:
> > static bool is_device_supported(struct rte_eth_dev *dev, struct eth_driver
> > *drv);
> O, forget to change it. Thanks.
> 
> > 
> > >  /* For Virtual Function support */
> > >  static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev); @@
> > > -4380,16 +4380,14 @@ static int
> > ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
> > >   ixgbe_add_rar(dev, addr, 0, 0);
> > >  }
> > >
> > > -static int
> > > -is_ixgbe_pmd(const char *driver_name)
> > > +static bool
> > > +is_device_supported(struct rte_eth_dev *dev, struct eth_driver *drv)
> > >  {
> > > - if (!strstr(driver_name, "ixgbe"))
> > > - return -ENOTSUP;
> > > + if (strcmp(dev->driver->pci_drv.driver.name,
> > > +drv->pci_drv.driver.name))
> > > + return FALSE;
> > >
> > 
> > It would be better to use `false' instead of `FALSE'.
> I see both 'false' and 'FALSE' are defined and used. Is there any reason that 
> 'false' is better?
> 

I think `true' and `false' are standard keywords defined and
reserved by C. So I think it would be better to use them if
the return type is `bool'.

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up rte_eth_dev_info_get

2017-02-05 Thread Tiwei Bie
On Mon, Feb 06, 2017 at 10:59:42AM +0800, Lu, Wenzhuo wrote:
> Hi Tiwei,
> 
> 
> > -Original Message-
> > From: Bie, Tiwei
> > Sent: Monday, February 6, 2017 10:51 AM
> > To: Lu, Wenzhuo
> > Cc: dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up rte_eth_dev_info_get
> > 
> > On Mon, Feb 06, 2017 at 10:41:28AM +0800, Lu, Wenzhuo wrote:
> > > Hi Tiwei,
> > >
> > > > -Original Message-
> > > > From: Bie, Tiwei
> > > > Sent: Monday, February 6, 2017 10:31 AM
> > > > To: Lu, Wenzhuo
> > > > Cc: dev@dpdk.org
> > > > Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up
> > > > rte_eth_dev_info_get
> > > >
> > > > On Mon, Feb 06, 2017 at 10:09:32AM +0800, Wenzhuo Lu wrote:
> > > > [...]
> > > > >  static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct
> > > > > ixgbe_dcb_config *dcb_config); -static int is_ixgbe_pmd(const char
> > > > > *driver_name);
> > > > > +static int is_device_supported(struct rte_eth_dev *dev, struct
> > > > > +eth_driver *drv);
> > > > >
> > > >
> > > > Should be:
> > > > static bool is_device_supported(struct rte_eth_dev *dev, struct
> > > > eth_driver *drv);
> > > O, forget to change it. Thanks.
> > >
> > > >
> > > > >  /* For Virtual Function support */  static int
> > > > > eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev); @@
> > > > > -4380,16 +4380,14 @@ static int
> > > > ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
> > > > >   ixgbe_add_rar(dev, addr, 0, 0);
> > > > >  }
> > > > >
> > > > > -static int
> > > > > -is_ixgbe_pmd(const char *driver_name)
> > > > > +static bool
> > > > > +is_device_supported(struct rte_eth_dev *dev, struct eth_driver
> > > > > +*drv)
> > > > >  {
> > > > > - if (!strstr(driver_name, "ixgbe"))
> > > > > - return -ENOTSUP;
> > > > > + if (strcmp(dev->driver->pci_drv.driver.name,
> > > > > +drv->pci_drv.driver.name))
> > > > > + return FALSE;
> > > > >
> > > >
> > > > It would be better to use `false' instead of `FALSE'.
> > > I see both 'false' and 'FALSE' are defined and used. Is there any reason 
> > > that
> > 'false' is better?
> > >
> > 
> > I think `true' and `false' are standard keywords defined and reserved by C. 
> > So I
> > think it would be better to use them if the return type is `bool'.
> O, there's no 'bool' in C. You have to define it. The same for 'false' and 
> 'true'.
> 

The `bool', `true' and `false' are all standard keywords defined and
reserved by C, although the stdbool.h is not used in ixgbe.

C adds this support by introducing a new header stdbool.h:

#ifndef __bool_true_false_are_defined
#define __bool_true_false_are_defined   1

#ifndef __cplusplus

#define false   0
#define true1

#define bool_Bool
#if __STDC_VERSION__ < 199901L && __GNUC__ < 3 && !defined(__INTEL_COMPILER)
typedef int _Bool;
#endif

#endif /* !__cplusplus */
#endif /* __bool_true_false_are_defined */

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up rte_eth_dev_info_get

2017-02-05 Thread Tiwei Bie
On Mon, Feb 06, 2017 at 11:45:41AM +0800, Lu, Wenzhuo wrote:
> Hi Tiwei,
> 
> > -Original Message-
> > From: Bie, Tiwei
> > Sent: Monday, February 6, 2017 11:08 AM
> > To: Lu, Wenzhuo
> > Cc: dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up rte_eth_dev_info_get
> > 
> > On Mon, Feb 06, 2017 at 10:59:42AM +0800, Lu, Wenzhuo wrote:
> > > Hi Tiwei,
> > >
> > >
> > > > -Original Message-
> > > > From: Bie, Tiwei
> > > > Sent: Monday, February 6, 2017 10:51 AM
> > > > To: Lu, Wenzhuo
> > > > Cc: dev@dpdk.org
> > > > Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up
> > > > rte_eth_dev_info_get
> > > >
> > > > On Mon, Feb 06, 2017 at 10:41:28AM +0800, Lu, Wenzhuo wrote:
> > > > > Hi Tiwei,
> > > > >
> > > > > > -Original Message-
> > > > > > From: Bie, Tiwei
> > > > > > Sent: Monday, February 6, 2017 10:31 AM
> > > > > > To: Lu, Wenzhuo
> > > > > > Cc: dev@dpdk.org
> > > > > > Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up
> > > > > > rte_eth_dev_info_get
> > > > > >
> > > > > > On Mon, Feb 06, 2017 at 10:09:32AM +0800, Wenzhuo Lu wrote:
> > > > > > [...]
> > > > > > >  static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct
> > > > > > > ixgbe_dcb_config *dcb_config); -static int is_ixgbe_pmd(const
> > > > > > > char *driver_name);
> > > > > > > +static int is_device_supported(struct rte_eth_dev *dev,
> > > > > > > +struct eth_driver *drv);
> > > > > > >
> > > > > >
> > > > > > Should be:
> > > > > > static bool is_device_supported(struct rte_eth_dev *dev, struct
> > > > > > eth_driver *drv);
> > > > > O, forget to change it. Thanks.
> > > > >
> > > > > >
> > > > > > >  /* For Virtual Function support */  static int
> > > > > > > eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev); @@
> > > > > > > -4380,16 +4380,14 @@ static int
> > > > > > ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev
> > > > > > *dev,
> > > > > > >   ixgbe_add_rar(dev, addr, 0, 0);  }
> > > > > > >
> > > > > > > -static int
> > > > > > > -is_ixgbe_pmd(const char *driver_name)
> > > > > > > +static bool
> > > > > > > +is_device_supported(struct rte_eth_dev *dev, struct
> > > > > > > +eth_driver
> > > > > > > +*drv)
> > > > > > >  {
> > > > > > > - if (!strstr(driver_name, "ixgbe"))
> > > > > > > - return -ENOTSUP;
> > > > > > > + if (strcmp(dev->driver->pci_drv.driver.name,
> > > > > > > +drv->pci_drv.driver.name))
> > > > > > > + return FALSE;
> > > > > > >
> > > > > >
> > > > > > It would be better to use `false' instead of `FALSE'.
> > > > > I see both 'false' and 'FALSE' are defined and used. Is there any
> > > > > reason that
> > > > 'false' is better?
> > > > >
> > > >
> > > > I think `true' and `false' are standard keywords defined and
> > > > reserved by C. So I think it would be better to use them if the return 
> > > > type is
> > `bool'.
> > > O, there's no 'bool' in C. You have to define it. The same for 'false' 
> > > and 'true'.
> > >
> > 
> > The `bool', `true' and `false' are all standard keywords defined and 
> > reserved by
> > C, although the stdbool.h is not used in ixgbe.
> > 
> > C adds this support by introducing a new header stdbool.h:
> > 
> > #ifndef __bool_true_false_are_defined
> > #define __bool_true_false_are_defined   1
> > 
> > #ifndef __cplusplus
> > 
> > #define false   0
> > #define true1
> > 
> > #define bool_Bool
> > #if __STDC_VERSION__ < 199901L && __GNUC__ < 3
> > && !defined(__INTEL_COMPILER)
> > typedef int _Bool;
> > #endif
> O, you're talking about C99. _Bool is a  keyword added by it. 'bool', 'true', 
> 'false' are  not. That's why this header file have to define them.
> 

C99 added all those as keyword, although doesn't implement
all of them as the builtin type (e.g. int). All of them are
standard keywords defined by C99. The `bool', `true' and
`false' are defined in section 7.16 of the C99 spec [1] and
implemented as macros:

7.16 Boolean type and values 

1 The header  defines four macros.

2 The macro
  bool
expands to _Bool.

3 The remaining three macros are suitable for use in #if preprocessing 
directives. They are
  true
which expands to the integer constant 1,
  false
which expands to the integer constant 0, and
  __bool_true_false_are_defined
which expands to the integer constant 1.

4 Notwithstanding the provisions of 7.1.3, a program may undefine and perhaps 
then redefine the macros bool, true, and false.222)

Footnotes

222) See ''future library directions'' (7.26.7).

[1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up rte_eth_dev_info_get

2017-02-05 Thread Tiwei Bie
; > >
> > > > > >
> > > > > > I think `true' and `false' are standard keywords defined and
> > > > > > reserved by C. So I think it would be better to use them if the
> > > > > > return type is
> > > > `bool'.
> > > > > O, there's no 'bool' in C. You have to define it. The same for 
> > > > > 'false' and
> > 'true'.
> > > > >
> > > >
> > > > The `bool', `true' and `false' are all standard keywords defined and
> > > > reserved by C, although the stdbool.h is not used in ixgbe.
> > > >
> > > > C adds this support by introducing a new header stdbool.h:
> > > >
> > > > #ifndef __bool_true_false_are_defined
> > > > #define __bool_true_false_are_defined   1
> > > >
> > > > #ifndef __cplusplus
> > > >
> > > > #define false   0
> > > > #define true1
> > > >
> > > > #define bool_Bool
> > > > #if __STDC_VERSION__ < 199901L && __GNUC__ < 3 &&
> > > > !defined(__INTEL_COMPILER)
> > > > typedef int _Bool;
> > > > #endif
> > > O, you're talking about C99. _Bool is a  keyword added by it. 'bool', 
> > > 'true',
> > 'false' are  not. That's why this header file have to define them.
> > >
> > 
> > C99 added all those as keyword, although doesn't implement all of them as
> > the builtin type (e.g. int). All of them are standard keywords defined by 
> > C99.
> > The `bool', `true' and `false' are defined in section 7.16 of the C99 spec 
> > [1] and
> > implemented as macros:
> > 
> > 7.16 Boolean type and values 
> > 
> > 1 The header  defines four macros.
> > 
> > 2 The macro
> >   bool
> > expands to _Bool.
> > 
> > 3 The remaining three macros are suitable for use in #if preprocessing
> > directives. They are
> >   true
> > which expands to the integer constant 1,
> >   false
> > which expands to the integer constant 0, and
> >   __bool_true_false_are_defined
> > which expands to the integer constant 1.
> > 
> > 4 Notwithstanding the provisions of 7.1.3, a program may undefine and
> > perhaps then redefine the macros bool, true, and false.222)
> > 
> > Footnotes
> > 
> > 222) See ''future library directions'' (7.26.7).
> > 
> > [1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
> O, I see the divergence. It's about the term 'keyword'. I only count '6.4.1 
> Keywords'. 
> Anyway, as both 'false'/'true' and 'FALSE'/'TRUE' are defined. I don’t know 
> why we cannot use any of them. If 'FALSE'/'TRUE' is not preferred, better 
> create a new patch to clean them up.
> 

I didn't say we cannot use FALSE/TRUE, I just suggested that false/true
would be better. :-)

I think the reason why introduce _Bool as builtin keyword and implement
others as macros is to provide applications the ability to redefine them
for compatibility issues. I think new code should follow the spec if
possible. :-)

Best regards,
Tiwei Bie


[dpdk-dev] [PATCH v2 0/4] Add MACsec offload support for ixgbe

2016-12-15 Thread Tiwei Bie
This patch set adds the MACsec offload support for ixgbe.
The testpmd is also updated to support MACsec cmds.

v2:
- Update the documents for testpmd;
- Update the release notes;
- Reuse the functions provided by base code;

Tiwei Bie (4):
  lib: add MACsec offload flags
  net/ixgbe: add MACsec offload support
  app/testpmd: add ixgbe MACsec offload support
  doc: add ixgbe specific APIs

 app/test-pmd/cmdline.c  | 389 +++
 app/test-pmd/macfwd.c   |   2 +
 app/test-pmd/macswap.c  |   2 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   2 +
 doc/guides/rel_notes/release_17_02.rst  |   6 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 ++
 drivers/net/ixgbe/ixgbe_ethdev.c| 476 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 100 ++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 lib/librte_ether/rte_ethdev.h   |   2 +
 lib/librte_mbuf/rte_mbuf.h  |   5 +
 14 files changed, 1070 insertions(+), 7 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH v2 1/4] lib: add MACsec offload flags

2016-12-15 Thread Tiwei Bie
These flags will be used in next commits in the ixgbe pmd.

Signed-off-by: Tiwei Bie 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 lib/librte_mbuf/rte_mbuf.h| 5 +
 2 files changed, 7 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 9678179..25a33e9 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -857,6 +857,7 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_TCP_LRO 0x0010
 #define DEV_RX_OFFLOAD_QINQ_STRIP  0x0020
 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x0040
+#define DEV_RX_OFFLOAD_MACSEC_STRIP 0x0080
 
 /**
  * TX offload capabilities of a device.
@@ -874,6 +875,7 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_GRE_TNL_TSO  0x0400/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_IPIP_TNL_TSO 0x0800/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO   0x1000/**< Used for tunneling 
packet. */
+#define DEV_TX_OFFLOAD_MACSEC_INSERT0x2000
 
 /**
  * Ethernet device information
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ead7c6e..b2073f0 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -182,6 +182,11 @@ extern "C" {
 /* add new TX flags here */
 
 /**
+ * MACsec offloading flag.
+ */
+#define PKT_TX_MACSEC(1ULL << 44)
+
+/**
  * Bits 45:48 used for the tunnel type.
  * When doing Tx offload like TSO or checksum, the HW needs to configure the
  * tunnel type into the HW descriptors.
-- 
2.7.4



[dpdk-dev] [PATCH v2 2/4] net/ixgbe: add MACsec offload support

2016-12-15 Thread Tiwei Bie
MACsec (or LinkSec, 802.1AE) is a MAC level encryption/authentication
scheme defined in IEEE 802.1AE that uses symmetric cryptography.
This commit adds the MACsec offload support for ixgbe.

Signed-off-by: Tiwei Bie 
---
 drivers/net/ixgbe/ixgbe_ethdev.c| 476 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 100 ++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 5 files changed, 628 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index edc9b22..6d32798 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -231,6 +231,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
uint16_t reta_size);
 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
+static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev);
@@ -744,6 +745,51 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_stats_strings[] = {
 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
   sizeof(rte_ixgbe_stats_strings[0]))
 
+/* MACsec statistics */
+static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
+   {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_untagged)},
+   {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_encrypted)},
+   {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_protected)},
+   {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_octets_encrypted)},
+   {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
+   out_octets_protected)},
+   {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_untagged)},
+   {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_badtag)},
+   {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_nosci)},
+   {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unknownsci)},
+   {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
+   in_octets_decrypted)},
+   {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
+   in_octets_validated)},
+   {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unchecked)},
+   {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_delayed)},
+   {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_late)},
+   {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_ok)},
+   {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_invalid)},
+   {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notvalid)},
+   {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unusedsa)},
+   {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notusingsa)},
+};
+
+#define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
+  sizeof(rte_ixgbe_macsec_strings[0]))
+
 /* Per-queue statistics */
 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
{"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
@@ -2380,6 +2426,8 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
rte_intr_dp_is_en(intr_handle))
ixgbe_dev_rxq_interrupt_setup(dev);
 
+   ixgbe_dev_macsec_interrupt_setup(dev);
+
/* enable uio/vfio intr/eventfd mapping */
rte_intr_enable(intr_handle);
 
@@ -2557,6 +2605,7 @@ ixgbe_dev_close(struct rte_eth_dev *dev)
 static void
 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
   struct ixgbe_hw_stats *hw_stats,
+  struct ixgbe_macsec_stats *macsec_stats,
   uint64_t *total_missed_rx, uint64_t *total_qbrc,
   uint64_t *total_qprc, uint64_t *total_qprdc)
 {
@@ -2726,6 +2775,40 @@ ixgbe_read_stats_registers(struct ixgbe_hw *hw,
/* Flow Director Stats registers */
hw_stats->fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH);
hw_stats->

[dpdk-dev] [PATCH v2 4/4] doc: add ixgbe specific APIs

2016-12-15 Thread Tiwei Bie
Add information about the new ixgbe PMD APIs in the release note.

Signed-off-by: Tiwei Bie 
---
 doc/guides/rel_notes/release_17_02.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 3b65038..c76cf5f 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -39,6 +39,12 @@ New Features
  =
 
 
+* **Added APIs for MACsec offload support to the ixgbe PMD.**
+
+  Six new APIs have been added to the ixgbe PMD for MACsec offload support.
+  The declarations for the APIs can be found in ``rte_pmd_ixgbe.h``.
+
+
 Resolved Issues
 ---
 
-- 
2.7.4



[dpdk-dev] [PATCH v2 3/4] app/testpmd: add ixgbe MACsec offload support

2016-12-15 Thread Tiwei Bie
- add test for set macsec offload
- add test for set macsec sc
- add test for set macsec sa

Also update the testpmd user guide.

Signed-off-by: Tiwei Bie 
---
 app/test-pmd/cmdline.c  | 389 
 app/test-pmd/macfwd.c   |   2 +
 app/test-pmd/macswap.c  |   2 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   2 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 +++
 6 files changed, 429 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index d03a592..635bb1f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -274,6 +274,18 @@ static void cmd_help_long_parsed(void *parsed_result,
 
"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
"Set MAC antispoof for a VF from the PF.\n\n"
+
+   "set macsec offload (port_id) on encrypt (on|off) 
replay-protect (on|off)\n"
+   "Enable MACsec offload.\n\n"
+
+   "set macsec offload (port_id) off\n"
+   "Disable MACsec offload.\n\n"
+
+   "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
+   "Configure MACsec secure connection (SC).\n\n"
+
+   "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) 
(key)\n"
+   "Configure MACsec secure association (SA).\n\n"
 #endif
 
"vlan set strip (on|off) (port_id)\n"
@@ -11457,6 +11469,379 @@ cmdline_parse_inst_t cmd_set_vf_mac_addr = {
NULL,
},
 };
+
+/* MACsec configuration */
+
+/* Common result structure for MACsec offload enable */
+struct cmd_macsec_offload_on_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t macsec;
+   cmdline_fixed_string_t offload;
+   uint8_t port_id;
+   cmdline_fixed_string_t on;
+   cmdline_fixed_string_t encrypt;
+   cmdline_fixed_string_t en_on_off;
+   cmdline_fixed_string_t replay_protect;
+   cmdline_fixed_string_t rp_on_off;
+};
+
+/* Common CLI fields for MACsec offload disable */
+cmdline_parse_token_string_t cmd_macsec_offload_on_set =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+set, "set");
+cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+macsec, "macsec");
+cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+offload, "offload");
+cmdline_parse_token_string_t cmd_macsec_offload_on_port_id =
+   TOKEN_NUM_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+port_id, UINT8);
+cmdline_parse_token_string_t cmd_macsec_offload_on_on =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+on, "on");
+cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+encrypt, "encrypt");
+cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+en_on_off, "on#off");
+cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+replay_protect, "replay-protect");
+cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+rp_on_off, "on#off");
+
+static void
+cmd_set_macsec_offload_on_parsed(
+   void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_macsec_offload_on_result *res = parsed_result;
+   int ret;
+   portid_t port_id = res->port_id;
+   int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
+   int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
+
+   if (port_id_is_invalid(port_id, ENABLED_WARN))
+   return;
+
+   ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
+   ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
+
+   switch (ret) {
+   case 0:
+   break;
+   case -ENODEV:
+   printf("invalid port_id %d\n", port_id);
+   break;
+   default:
+   printf("programming error: (%s)\

[dpdk-dev] [PATCH v3 1/6] mbuf: add flag for MACsec

2016-12-25 Thread Tiwei Bie
Add a new Tx flag in mbuf, that can be set by applications to
enable the MACsec offload for a packet to be transmitted.

Signed-off-by: Tiwei Bie 
---
 doc/guides/rel_notes/release_17_02.rst | 5 +
 lib/librte_mbuf/rte_mbuf.c | 2 ++
 lib/librte_mbuf/rte_mbuf.h | 6 ++
 3 files changed, 13 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 180af82..d278b3f 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,11 @@ New Features
   See the :ref:`Generic flow API ` documentation for more
   information.
 
+* **Improved offload support in mbuf.**
+
+  Added a new Tx MACsec mbuf flag, set by applications to enable the MACsec
+  offload for a packet to be transmitted.
+
 
 Resolved Issues
 ---
diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 63f43c8..72ad91e 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -404,6 +404,7 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
case PKT_TX_TUNNEL_GRE: return "PKT_TX_TUNNEL_GRE";
case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
+   case PKT_TX_MACSEC: return "PKT_TX_MACSEC";
default: return NULL;
}
 }
@@ -434,6 +435,7 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t 
buflen)
  "PKT_TX_TUNNEL_NONE" },
{ PKT_TX_TUNNEL_GENEVE, PKT_TX_TUNNEL_MASK,
  "PKT_TX_TUNNEL_NONE" },
+   { PKT_TX_MACSEC, PKT_TX_MACSEC, NULL },
};
const char *name;
unsigned int i;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ead7c6e..752dca4 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -182,6 +182,12 @@ extern "C" {
 /* add new TX flags here */
 
 /**
+ * Offload the MACsec. This flag must be set by the application to enable
+ * this offload feature for a packet to be transmitted.
+ */
+#define PKT_TX_MACSEC(1ULL << 44)
+
+/**
  * Bits 45:48 used for the tunnel type.
  * When doing Tx offload like TSO or checksum, the HW needs to configure the
  * tunnel type into the HW descriptors.
-- 
2.7.4



[dpdk-dev] [PATCH v3 0/6] Add MACsec offload support for ixgbe

2016-12-25 Thread Tiwei Bie
This patch set adds the MACsec offload support for ixgbe.
The testpmd is also updated to support MACsec cmds.

v2:
- Update the documents for testpmd;
- Update the release notes;
- Reuse the functions provided by base code;

v3:
- Add the missing parts of MACsec mbuf flag and reorganize the patch set;
- Add an ethdev event type for MACsec;
- Advertise the MACsec offload capabilities based on the mac type;
- Minor fixes and improvements;

Tiwei Bie (6):
  mbuf: add flag for MACsec
  ethdev: add event type for MACsec
  ethdev: add MACsec offload capability flags
  net/ixgbe: add MACsec offload support
  app/testpmd: add MACsec offload commands
  doc: add ixgbe specific APIs

 app/test-pmd/cmdline.c  | 389 ++
 app/test-pmd/macfwd.c   |   2 +
 app/test-pmd/macswap.c  |   2 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   2 +
 doc/guides/rel_notes/release_17_02.rst  |  10 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 ++
 drivers/net/ixgbe/ixgbe_ethdev.c| 481 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 100 ++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 lib/librte_ether/rte_ethdev.h   |   3 +
 lib/librte_mbuf/rte_mbuf.c  |   2 +
 lib/librte_mbuf/rte_mbuf.h  |   6 +
 15 files changed, 1085 insertions(+), 5 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH v3 2/6] ethdev: add event type for MACsec

2016-12-25 Thread Tiwei Bie
This commit adds a below event type:

- RTE_ETH_EVENT_MACSEC

This event will occur when the PN counter in a MACsec connection
reaches the exhaustion threshold.

Signed-off-by: Tiwei Bie 
---
 lib/librte_ether/rte_ethdev.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 272fd41..b0b2678 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3043,6 +3043,7 @@ enum rte_eth_event_type {
RTE_ETH_EVENT_INTR_RESET,
/**< reset interrupt event, sent to VF on PF reset */
RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
+   RTE_ETH_EVENT_MACSEC,   /**< MACsec offload related event */
RTE_ETH_EVENT_MAX   /**< max value of this enum */
 };
 
-- 
2.7.4



[dpdk-dev] [PATCH v3 6/6] doc: add ixgbe specific APIs

2016-12-25 Thread Tiwei Bie
Add information about the new ixgbe PMD APIs in the release note.

Signed-off-by: Tiwei Bie 
Acked-by: John McNamara 
---
 doc/guides/rel_notes/release_17_02.rst | 5 +
 1 file changed, 5 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index d278b3f..867991d 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,11 @@ New Features
   See the :ref:`Generic flow API ` documentation for more
   information.
 
+* **Added APIs for MACsec offload support to the ixgbe PMD.**
+
+  Six new APIs have been added to the ixgbe PMD for MACsec offload support.
+  The declarations for the APIs can be found in ``rte_pmd_ixgbe.h``.
+
 * **Improved offload support in mbuf.**
 
   Added a new Tx MACsec mbuf flag, set by applications to enable the MACsec
-- 
2.7.4



[dpdk-dev] [PATCH v3 4/6] net/ixgbe: add MACsec offload support

2016-12-25 Thread Tiwei Bie
MACsec (or LinkSec, 802.1AE) is a MAC level encryption/authentication
scheme defined in IEEE 802.1AE that uses symmetric cryptography.
This commit adds the MACsec offload support for ixgbe.

Signed-off-by: Tiwei Bie 
---
 drivers/net/ixgbe/ixgbe_ethdev.c| 481 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 100 ++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 5 files changed, 635 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index baffc71..a06ed07 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -231,6 +231,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
uint16_t reta_size);
 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
+static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev);
@@ -744,6 +745,51 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_stats_strings[] = {
 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
   sizeof(rte_ixgbe_stats_strings[0]))
 
+/* MACsec statistics */
+static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
+   {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_untagged)},
+   {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_encrypted)},
+   {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_protected)},
+   {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_octets_encrypted)},
+   {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
+   out_octets_protected)},
+   {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_untagged)},
+   {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_badtag)},
+   {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_nosci)},
+   {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unknownsci)},
+   {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
+   in_octets_decrypted)},
+   {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
+   in_octets_validated)},
+   {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unchecked)},
+   {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_delayed)},
+   {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_late)},
+   {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_ok)},
+   {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_invalid)},
+   {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notvalid)},
+   {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unusedsa)},
+   {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notusingsa)},
+};
+
+#define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
+  sizeof(rte_ixgbe_macsec_strings[0]))
+
 /* Per-queue statistics */
 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
{"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
@@ -2366,6 +2412,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
/* check if lsc interrupt is enabled */
if (dev->data->dev_conf.intr_conf.lsc != 0)
ixgbe_dev_lsc_interrupt_setup(dev);
+   ixgbe_dev_macsec_interrupt_setup(dev);
} else {
rte_intr_callback_unregister(intr_handle,
 ixgbe_dev_interrupt_handler,
@@ -2557,6 +2604,7 @@ ixgbe_dev_close(struct rte_eth_dev *dev)
 static void
 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
   struct ixgbe_hw_stats *hw_stats,
+  struct ixgbe_macsec_stats *macsec_stats,
   uint64_t *total_missed_rx, uint64_t *total_qbrc,
   uint64_t *total_qprc, uint64_t *total_qprdc)
 {
@@ -2726,6 +2774,40 @@ ixgbe_read_stats_registers(struct ixgbe

[dpdk-dev] [PATCH v3 3/6] ethdev: add MACsec offload capability flags

2016-12-25 Thread Tiwei Bie
If these flags are advertised by a PMD, the NIC supports the MACsec
offload. The incoming MACsec traffics can be offloaded transparently
after the MACsec offload is configured correctly by the application.
And the application can set the PKT_TX_MACSEC flag in mbufs to enable
the MACsec offload for the packets to be transmitted.

Signed-off-by: Tiwei Bie 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index b0b2678..faec56f 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -857,6 +857,7 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_TCP_LRO 0x0010
 #define DEV_RX_OFFLOAD_QINQ_STRIP  0x0020
 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x0040
+#define DEV_RX_OFFLOAD_MACSEC_STRIP 0x0080
 
 /**
  * TX offload capabilities of a device.
@@ -874,6 +875,7 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_GRE_TNL_TSO  0x0400/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_IPIP_TNL_TSO 0x0800/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO   0x1000/**< Used for tunneling 
packet. */
+#define DEV_TX_OFFLOAD_MACSEC_INSERT0x2000
 
 /**
  * Ethernet device information
-- 
2.7.4



[dpdk-dev] [PATCH v3 5/6] app/testpmd: add MACsec offload commands

2016-12-25 Thread Tiwei Bie
Below MACsec offload commands are added:

- set macsec offload  on encrypt on|off replay-protect on|off
- set macsec offload  off
- set macsec sc tx|rx   
- set macsec sa tx|rx 

Also update the testpmd user guide.

Signed-off-by: Tiwei Bie 
---
 app/test-pmd/cmdline.c  | 389 
 app/test-pmd/macfwd.c   |   2 +
 app/test-pmd/macswap.c  |   2 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   2 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 +++
 6 files changed, 429 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f768b6b..4a67894 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -275,6 +275,18 @@ static void cmd_help_long_parsed(void *parsed_result,
 
"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
"Set MAC antispoof for a VF from the PF.\n\n"
+
+   "set macsec offload (port_id) on encrypt (on|off) 
replay-protect (on|off)\n"
+   "Enable MACsec offload.\n\n"
+
+   "set macsec offload (port_id) off\n"
+   "Disable MACsec offload.\n\n"
+
+   "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
+   "Configure MACsec secure connection (SC).\n\n"
+
+   "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) 
(key)\n"
+   "Configure MACsec secure association (SA).\n\n"
 #endif
 
"vlan set strip (on|off) (port_id)\n"
@@ -11488,6 +11500,379 @@ cmdline_parse_inst_t cmd_set_vf_mac_addr = {
NULL,
},
 };
+
+/* MACsec configuration */
+
+/* Common result structure for MACsec offload enable */
+struct cmd_macsec_offload_on_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t macsec;
+   cmdline_fixed_string_t offload;
+   uint8_t port_id;
+   cmdline_fixed_string_t on;
+   cmdline_fixed_string_t encrypt;
+   cmdline_fixed_string_t en_on_off;
+   cmdline_fixed_string_t replay_protect;
+   cmdline_fixed_string_t rp_on_off;
+};
+
+/* Common CLI fields for MACsec offload disable */
+cmdline_parse_token_string_t cmd_macsec_offload_on_set =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+set, "set");
+cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+macsec, "macsec");
+cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+offload, "offload");
+cmdline_parse_token_string_t cmd_macsec_offload_on_port_id =
+   TOKEN_NUM_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+port_id, UINT8);
+cmdline_parse_token_string_t cmd_macsec_offload_on_on =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+on, "on");
+cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+encrypt, "encrypt");
+cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+en_on_off, "on#off");
+cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+replay_protect, "replay-protect");
+cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+rp_on_off, "on#off");
+
+static void
+cmd_set_macsec_offload_on_parsed(
+   void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_macsec_offload_on_result *res = parsed_result;
+   int ret;
+   portid_t port_id = res->port_id;
+   int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
+   int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
+
+   if (port_id_is_invalid(port_id, ENABLED_WARN))
+   return;
+
+   ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
+   ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
+
+   switch (ret) {
+   case 0:
+   break;
+   case -ENODEV:
+   printf("invalid port_id %d\n", po

Re: [dpdk-dev] [PATCH v3 0/6] Add MACsec offload support for ixgbe

2016-12-26 Thread Tiwei Bie
Hi Adrien,

On Mon, Dec 26, 2016 at 04:15:37PM +0100, Adrien Mazarguil wrote:
> Hi Tiwei,
> 
> On Sun, Dec 25, 2016 at 10:57:54PM +0800, Tiwei Bie wrote:
> > This patch set adds the MACsec offload support for ixgbe.
> > The testpmd is also updated to support MACsec cmds.
> 
> I'm not commenting on any specific patch from this series, however I'm
> noticing this new trend of working around ethdev to add PMD-specific APIs.
> I would like to make sure it's not getting out of hand.
> 
> To use the "rte_pmd_ixgbe_macsec_*()" API, applications must be linked with
> librte_pmd_ixgbe directly and have the related code under #ifdef
> RTE_LIBRTE_IXGBE_PMD like testpmd.
> 
> Here we can see this ixgbe-specific API affects rte_mbuf.h and rte_ethdev.h
> (new PKT_TX_MACSEC, RTE_ETH_EVENT_MACSEC, DEV_RX_OFFLOAD_MACSEC_STRIP and
> DEV_TX_OFFLOAD_MACSEC_INSERT flags).
> 
> - Shouldn't these flags have "IXGBE" somewhere in their name and/or be
>   defined under #ifdef RTE_LIBRTE_IXGBE_PMD? 
> 

I think those flags are very generic, simple and innocent, so we could just
define them in the normal way. And currently it seems that we lack a way to
define the PMD-specific flags for mbuf, ethdev, etc.

> - Why can't the MACsec API be defined globally, for instance won't i40e
>   implement it as well someday?
> 

I think currently we prefer to implement some PMD features based on the
PMD-specific APIs at first to avoid the bloating of the ethdev APIs. And
when it proves to be generic (which means many people really need it and
care about it, and more drivers are really going to implement it), then
we make it as the global ethdev API.

> - Why bothering with TX/RX offload capabilities if applications know the
>   underlying PMD anyway?
> 

Not every NIC supported by IXGBE supports the MACsec offload. So even
if the application knows it's using IXGBE PMD, it still needs to check
whether the MACsec offload capabilities are supported.

> Assuming these patches are kept as-is, I suggest we define a reserved space
> documented as such for PMD-specific flags wherever they are used.
> 

It sounds good to me. But it may involve many pieces of the lib, such
as the mbuf ol_flags, ethdev event type, ethdev offload capabilities,
and so on. So maybe it can be done as another work.

Thank you very much for your comments! :-)

Best regards,
Tiwei Bie

> > v2:
> > - Update the documents for testpmd;
> > - Update the release notes;
> > - Reuse the functions provided by base code;
> > 
> > v3:
> > - Add the missing parts of MACsec mbuf flag and reorganize the patch set;
> > - Add an ethdev event type for MACsec;
> > - Advertise the MACsec offload capabilities based on the mac type;
> > - Minor fixes and improvements;
> > 
> > Tiwei Bie (6):
> >   mbuf: add flag for MACsec
> >   ethdev: add event type for MACsec
> >   ethdev: add MACsec offload capability flags
> >   net/ixgbe: add MACsec offload support
> >   app/testpmd: add MACsec offload commands
> >   doc: add ixgbe specific APIs
> > 
> >  app/test-pmd/cmdline.c  | 389 ++
> >  app/test-pmd/macfwd.c   |   2 +
> >  app/test-pmd/macswap.c  |   2 +
> >  app/test-pmd/testpmd.h  |   2 +
> >  app/test-pmd/txonly.c   |   2 +
> >  doc/guides/rel_notes/release_17_02.rst  |  10 +
> >  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 ++
> >  drivers/net/ixgbe/ixgbe_ethdev.c| 481 
> > +++-
> >  drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
> >  drivers/net/ixgbe/ixgbe_rxtx.c  |   3 +
> >  drivers/net/ixgbe/rte_pmd_ixgbe.h   | 100 ++
> >  drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
> >  lib/librte_ether/rte_ethdev.h   |   3 +
> >  lib/librte_mbuf/rte_mbuf.c  |   2 +
> >  lib/librte_mbuf/rte_mbuf.h  |   6 +
> >  15 files changed, 1085 insertions(+), 5 deletions(-)
> > 
> > -- 
> > 2.7.4
> > 
> 
> -- 
> Adrien Mazarguil
> 6WIND


Re: [dpdk-dev] [PATCH v3 0/6] Add MACsec offload support for ixgbe

2016-12-27 Thread Tiwei Bie
Hi Adrien,

On Tue, Dec 27, 2016 at 03:37:46PM +0100, Adrien Mazarguil wrote:
> Hi Tiwei,
> 
> On Tue, Dec 27, 2016 at 09:33:31AM +0800, Tiwei Bie wrote:
> > Hi Adrien,
> > 
> > On Mon, Dec 26, 2016 at 04:15:37PM +0100, Adrien Mazarguil wrote:
> > > Hi Tiwei,
> > > 
> > > On Sun, Dec 25, 2016 at 10:57:54PM +0800, Tiwei Bie wrote:
> > > > This patch set adds the MACsec offload support for ixgbe.
> > > > The testpmd is also updated to support MACsec cmds.
[...]
> > > - Why can't the MACsec API be defined globally, for instance won't i40e
> > >   implement it as well someday?
> > 
> > I think currently we prefer to implement some PMD features based on the
> > PMD-specific APIs at first to avoid the bloating of the ethdev APIs. And
> > when it proves to be generic (which means many people really need it and
> > care about it, and more drivers are really going to implement it), then
> > we make it as the global ethdev API.
> 
> Understandable, but then unless the global API remains exactly the same
> including the "rte_ixgbe_macsec" prefix (which I think won't happen),
> applications need to be rewritten, it's not convenient, and as a result may
> prevent adoption due to the following cycle:
> 
> - Applications wait for the API to evolve before using MACsec.
> - DPDK waits for applications to use the ixgbe MACsec API to improve it.
> 

Yeah, I also saw these problems. And I also don't think this is a
perfect way. But it seems that many of us prefer this way, so I just
choose to accept it.

> In the end, flags tied to a single PMD remain allocated in the global
> namespace while the API is kept in this temporary state forever.
> 
> I think doing the extra work to make it global from the start is worth the
> trouble. This step could perhaps be made easier if people agreed that
> struct eth_dev_ops (and friends) must be opaque to applications.
> 
[...]
> 
> > > Assuming these patches are kept as-is, I suggest we define a reserved 
> > > space
> > > documented as such for PMD-specific flags wherever they are used.
> > > 
> > 
> > It sounds good to me. But it may involve many pieces of the lib, such
> > as the mbuf ol_flags, ethdev event type, ethdev offload capabilities,
> > and so on. So maybe it can be done as another work.
> 
> Right, that was just an idea from the top of my head, we could define
> reserved values only when they become necessary for a PMD as in this case,
> e.g. instead of defining PKT_TX_MACSEC, one would define PKT_TX_RESERVED_0
> which would be interpreted as MACSEC by ixgbe until this API is exposed
> globally.
> 
> Other PMDs could implement other unrelated PMD-specific APIs through
> RESERVED_0 in the meantime, so we preserve the precious space we have
> for global APIs (especially inside mbufs).
> 
> Thoughts?
> 

When a certain PMD implemented several different features based on
the PMD-specific API, and many of them need to define some flags in
mbuf or the like, it still needs to waste many bits (i.e. we'll need
to reserve many bits by that time). But any way, I love your idea!
It's much better than the current approach! I'll update my patch.
Thank you very much! ;-)

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2 01/17] net/i40e: store ethertype filter

2016-12-27 Thread Tiwei Bie
n should return when ret < 0.

> + ethertype_rule->hash_map[ret] = filter;
> +
> + TAILQ_INSERT_TAIL(ðertype_rule->ethertype_list, filter, rules);
> +
> + return 0;
> +}
> +
> +/* Delete ethertype filter in SW list */
> +static int
> +i40e_sw_ethertype_filter_del(struct i40e_pf *pf,
> +  struct i40e_ethertype_filter *filter)
> +{
> + struct i40e_ethertype_rule *ethertype_rule = &pf->ethertype;
> + int ret = 0;
> +

Same here.

> + ret = rte_hash_del_key(ethertype_rule->hash_table,
> +&filter->input);
> + if (ret < 0)
> + PMD_DRV_LOG(ERR,
> + "Failed to delete ethertype filter"
> + " to hash table %d!",
> + ret);

Function should return when ret < 0.

> + ethertype_rule->hash_map[ret] = NULL;
> +
> + TAILQ_REMOVE(ðertype_rule->ethertype_list, filter, rules);
> + rte_free(filter);
> +
> + return 0;
> +}
> +
>  /*
>   * Configure ethertype filter, which can director packet by filtering
>   * with mac address and ether_type or only ether_type
> @@ -7964,6 +8099,8 @@ i40e_ethertype_filter_set(struct i40e_pf *pf,
>   bool add)
>  {
>   struct i40e_hw *hw = I40E_PF_TO_HW(pf);
> + struct i40e_ethertype_rule *ethertype_rule = &pf->ethertype;
> + struct i40e_ethertype_filter *ethertype_filter, *node;
>   struct i40e_control_filter_stats stats;
>   uint16_t flags = 0;
>   int ret;
> @@ -7982,6 +8119,22 @@ i40e_ethertype_filter_set(struct i40e_pf *pf,
>   PMD_DRV_LOG(WARNING, "filter vlan ether_type in first tag is"
>   " not supported.");
>  
> + /* Check if there is the filter in SW list */
> + ethertype_filter = rte_zmalloc("ethertype_filter",
> +sizeof(*ethertype_filter), 0);
> + i40e_ethertype_filter_convert(filter, ethertype_filter);
> + node = i40e_sw_ethertype_filter_lookup(ethertype_rule,
> +ðertype_filter->input);
> + if (add && node) {
> + PMD_DRV_LOG(ERR, "Conflict with existing ethertype rules!");
> + rte_free(ethertype_filter);
> + return -EINVAL;
> + } else if (!add && !node) {

When `if (add && node)' is true, function will return. There is no need
to use `else' here.

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2 02/17] net/i40e: store tunnel filter

2016-12-27 Thread Tiwei Bie
el filter to hash table %d!",
> + ret);

Function should return when ret < 0.

> + tunnel_rule->hash_map[ret] = NULL;
> +
> + TAILQ_REMOVE(&tunnel_rule->tunnel_list, tunnel_filter, rules);
> + rte_free(tunnel_filter);
> +
> + return 0;
> +}
> +
>  static int
>  i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
>   struct rte_eth_tunnel_filter_conf *tunnel_filter,
> @@ -6497,6 +6631,8 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
>   struct i40e_vsi *vsi = pf->main_vsi;
>   struct i40e_aqc_add_remove_cloud_filters_element_data  *cld_filter;
>   struct i40e_aqc_add_remove_cloud_filters_element_data  *pfilter;
> + struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
> + struct i40e_tunnel_filter *tunnel, *node;
>  
>   cld_filter = rte_zmalloc("tunnel_filter",
>   sizeof(struct i40e_aqc_add_remove_cloud_filters_element_data),
> @@ -6559,11 +6695,36 @@ i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
>   pfilter->tenant_id = rte_cpu_to_le_32(tunnel_filter->tenant_id);
>   pfilter->queue_number = rte_cpu_to_le_16(tunnel_filter->queue_id);
>  
> - if (add)
> + tunnel = rte_zmalloc("tunnel_filter", sizeof(*tunnel), 0);
> + i40e_tunnel_filter_convert(cld_filter, tunnel);
> + node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &tunnel->input);
> + if (add && node) {
> + PMD_DRV_LOG(ERR, "Conflict with existing tunnel rules!");
> + rte_free(tunnel);
> + return -EINVAL;
> + } else if (!add && !node) {

When `if (add && node)' is true, function will return. There is no need
to use `else' here.

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2 03/17] net/i40e: store flow director filter

2016-12-27 Thread Tiwei Bie
On Tue, Dec 27, 2016 at 02:26:10PM +0800, Beilei Xing wrote:
> Currently there's no flow director filter stored in SW. This
> patch stores flow director filters in SW with cuckoo hash,
> also adds protection if a flow director filter has been added.
> 
> Signed-off-by: Beilei Xing 
> ---
>  drivers/net/i40e/i40e_ethdev.c | 48 +
>  drivers/net/i40e/i40e_ethdev.h | 12 ++
>  drivers/net/i40e/i40e_fdir.c   | 98 
> ++
>  3 files changed, 158 insertions(+)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index c012d5d..427ebdc 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
[...]
> @@ -1342,6 +1379,17 @@ eth_i40e_dev_uninit(struct rte_eth_dev *dev)
>   rte_free(p_tunnel);
>   }
>  
> + /* Remove all flow director rules and hash */
> + if (fdir_info->hash_map)
> + rte_free(fdir_info->hash_map);
> + if (fdir_info->hash_table)
> + rte_hash_free(fdir_info->hash_table);
> +
> + while ((p_fdir = TAILQ_FIRST(&fdir_info->fdir_list))) {

There is a redundant pair of parentheses, or you should compare with
NULL.

> + TAILQ_REMOVE(&fdir_info->fdir_list, p_fdir, rules);
> + rte_free(p_fdir);
> + }
> +
>   dev->dev_ops = NULL;
>   dev->rx_pkt_burst = NULL;
>   dev->tx_pkt_burst = NULL;
[...]
> diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
> index 335bf15..faa2495 100644
> --- a/drivers/net/i40e/i40e_fdir.c
> +++ b/drivers/net/i40e/i40e_fdir.c
[...]
> +/* Check if there exists the flow director filter */
> +static struct i40e_fdir_filter *
> +i40e_sw_fdir_filter_lookup(struct i40e_fdir_info *fdir_info,
> + const struct rte_eth_fdir_input *input)
> +{
> + int ret = 0;
> +

The initialization is meaningless, as it will be written by the below
assignment unconditionally.

> + ret = rte_hash_lookup(fdir_info->hash_table, (const void *)input);
> + if (ret < 0)
> + return NULL;
> +
> + return fdir_info->hash_map[ret];
> +}
> +
> +/* Add a flow director filter into the SW list */
> +static int
> +i40e_sw_fdir_filter_insert(struct i40e_pf *pf, struct i40e_fdir_filter 
> *filter)
> +{
> + struct i40e_fdir_info *fdir_info = &pf->fdir;
> + int ret = 0;
> +

Same here.

> + ret = rte_hash_add_key(fdir_info->hash_table,
> +&filter->fdir.input);
> + if (ret < 0)
> + PMD_DRV_LOG(ERR,
> + "Failed to insert fdir filter to hash table %d!",
> + ret);

Function should return when ret < 0.

> + fdir_info->hash_map[ret] = filter;
> +
> + TAILQ_INSERT_TAIL(&fdir_info->fdir_list, filter, rules);
> +
> + return 0;
> +}
> +
> +/* Delete a flow director filter from the SW list */
> +static int
> +i40e_sw_fdir_filter_del(struct i40e_pf *pf, struct i40e_fdir_filter *filter)
> +{
> + struct i40e_fdir_info *fdir_info = &pf->fdir;
> + int ret = 0;
> +

Same here.

> + ret = rte_hash_del_key(fdir_info->hash_table,
> +&filter->fdir.input);
> + if (ret < 0)
> + PMD_DRV_LOG(ERR,
> + "Failed to delete fdir filter to hash table %d!",
> + ret);

Function should return when ret < 0.

> + fdir_info->hash_map[ret] = NULL;
> +
> + TAILQ_REMOVE(&fdir_info->fdir_list, filter, rules);
> + rte_free(filter);
> +
> + return 0;
> +}
> +
>  /*
>   * i40e_add_del_fdir_filter - add or remove a flow director filter.
>   * @pf: board private structure
> @@ -1032,6 +1105,8 @@ i40e_add_del_fdir_filter(struct rte_eth_dev *dev,
>   struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
>   unsigned char *pkt = (unsigned char *)pf->fdir.prg_pkt;
>   enum i40e_filter_pctype pctype;
> + struct i40e_fdir_info *fdir_info = &pf->fdir;
> + struct i40e_fdir_filter *fdir_filter, *node;
>   int ret = 0;
>  
>   if (dev->data->dev_conf.fdir_conf.mode != RTE_FDIR_MODE_PERFECT) {
> @@ -1054,6 +1129,21 @@ i40e_add_del_fdir_filter(struct rte_eth_dev *dev,
>   return -EINVAL;
>   }
>  
> + fdir_filter = rte_zmalloc("fdir_filter", sizeof(*fdir_filter), 0);
> + i40e_fdir_filter_convert(filter, fdir_filter);
> + node = i40e_sw_fdir_filter_lookup(fdir_info, &fdir_filter->fdir.input);
> + if (add && node) {
> + PMD_DRV_LOG(ERR,
> + "Conflict with existing flow director rules!");
> + rte_free(fdir_filter);
> + return -EINVAL;
> + } else if (!add && !node) {

When `if (add && node)' is true, function will return. There is no need
to use `else' here.

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2 07/17] net/i40e: add flow validate function

2016-12-27 Thread Tiwei Bie
On Tue, Dec 27, 2016 at 02:26:14PM +0800, Beilei Xing wrote:
> This patch adds i40e_flow_validation function to check if
> a flow is valid according to the flow pattern.
> i40e_parse_ethertype_filter is added first, it also gets
> the ethertype info.
> i40e_flow.c is added to handle all generic filter events.
> 
> Signed-off-by: Beilei Xing 
> ---
>  drivers/net/i40e/Makefile  |   1 +
>  drivers/net/i40e/i40e_ethdev.c |   5 +
>  drivers/net/i40e/i40e_ethdev.h |  20 ++
>  drivers/net/i40e/i40e_flow.c   | 431 
> +
>  4 files changed, 457 insertions(+)
>  create mode 100644 drivers/net/i40e/i40e_flow.c
> 
> diff --git a/drivers/net/i40e/Makefile b/drivers/net/i40e/Makefile
> index 11175c4..89bd85a 100644
> --- a/drivers/net/i40e/Makefile
> +++ b/drivers/net/i40e/Makefile
> @@ -105,6 +105,7 @@ endif
>  SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_ethdev_vf.c
>  SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_pf.c
>  SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_fdir.c
> +SRCS-$(CONFIG_RTE_LIBRTE_I40E_PMD) += i40e_flow.c
>  
>  # vector PMD driver needs SSE4.1 support
>  ifeq ($(findstring RTE_MACHINE_CPUFLAG_SSE4_1,$(CFLAGS)),)
> diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c
> index 7f98b79..80024ed 100644
> --- a/drivers/net/i40e/i40e_ethdev.c
> +++ b/drivers/net/i40e/i40e_ethdev.c
> @@ -8452,6 +8452,11 @@ i40e_dev_filter_ctrl(struct rte_eth_dev *dev,
>   case RTE_ETH_FILTER_FDIR:
>   ret = i40e_fdir_ctrl_func(dev, filter_op, arg);
>   break;
> + case RTE_ETH_FILTER_GENERIC:
> + if (filter_op != RTE_ETH_FILTER_GET)
> + return -EINVAL;
> + *(const void **)arg = &i40e_flow_ops;
> + break;
>   default:
>   PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
>   filter_type);
> diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
> index 6089895..bbe52f0 100644
> --- a/drivers/net/i40e/i40e_ethdev.h
> +++ b/drivers/net/i40e/i40e_ethdev.h
> @@ -38,6 +38,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #define I40E_VLAN_TAG_SIZE4
>  
> @@ -629,6 +630,23 @@ struct i40e_adapter {
>   struct rte_timecounter tx_tstamp_tc;
>  };
>  
> +union i40e_filter_t {
> + struct rte_eth_ethertype_filter ethertype_filter;
> + struct rte_eth_fdir_filter fdir_filter;
> + struct rte_eth_tunnel_filter_conf tunnel_filter;
> +} cons_filter;
> +

Are you sure that you want to define a variable in i40e_ethdev.h?

> +typedef int (*parse_filter_t)(struct rte_eth_dev *dev,
> +   const struct rte_flow_attr *attr,
> +   const struct rte_flow_item pattern[],
> +   const struct rte_flow_action actions[],
> +   struct rte_flow_error *error,
> +   union i40e_filter_t *filter);
> +struct i40e_valid_pattern {
> + enum rte_flow_item_type *items;
> + parse_filter_t parse_filter;
> +};
> +
>  int i40e_dev_switch_queues(struct i40e_pf *pf, bool on);
>  int i40e_vsi_release(struct i40e_vsi *vsi);
>  struct i40e_vsi *i40e_vsi_setup(struct i40e_pf *pf,
> @@ -823,4 +841,6 @@ i40e_calc_itr_interval(int16_t interval)
>   ((phy_type) & I40E_CAP_PHY_TYPE_25GBASE_SR) || \
>   ((phy_type) & I40E_CAP_PHY_TYPE_25GBASE_LR))
>  
> +const struct rte_flow_ops i40e_flow_ops;
> +

Same here. Are you sure that you want to define a variable in i40e_ethdev.h?
Maybe you should add the `extern' qualifier.

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2 12/17] net/i40e: destroy ethertype filter

2016-12-27 Thread Tiwei Bie
On Tue, Dec 27, 2016 at 02:26:19PM +0800, Beilei Xing wrote:
> This patch adds i40e_dev_destroy_ethertype_filter function
> to destroy a ethertype filter for users.
> 
> Signed-off-by: Beilei Xing 
> ---
>  drivers/net/i40e/i40e_ethdev.c | 10 ++---
>  drivers/net/i40e/i40e_ethdev.h |  5 +
>  drivers/net/i40e/i40e_flow.c   | 51 
> --
>  3 files changed, 56 insertions(+), 10 deletions(-)
> 
[...]
> diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
> index 2a61c4f..732c411 100644
> --- a/drivers/net/i40e/i40e_flow.c
> +++ b/drivers/net/i40e/i40e_flow.c
[...]
> @@ -1492,11 +1495,16 @@ i40e_flow_destroy(__rte_unused struct rte_eth_dev 
> *dev,

The `__rte_unused' qualifier should be removed.

> struct rte_flow *flow,
> struct rte_flow_error *error)
>  {
> + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
>   struct i40e_flow *pmd_flow = (struct i40e_flow *)flow;
>   enum rte_filter_type filter_type = pmd_flow->filter_type;
>   int ret;
>  
>   switch (filter_type) {
> + case RTE_ETH_FILTER_ETHERTYPE:
> + ret = i40e_dev_destroy_ethertype_filter(pf,
> + (struct i40e_ethertype_filter *)pmd_flow->rule);
> + break;
>   default:
>   PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
>   filter_type);
> @@ -1504,10 +1512,49 @@ i40e_flow_destroy(__rte_unused struct rte_eth_dev 
> *dev,
>   break;
>   }
>  
> - if (ret)
> + if (!ret) {
> + TAILQ_REMOVE(&pf->flow_list, pmd_flow, node);
> + free(pmd_flow);
> + } else {
>   rte_flow_error_set(error, EINVAL,
>  RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
>  "Failed to destroy flow.");
> + }

Probably you should introduce the pf related code when introducing
i40e_flow_destroy() in the below patch:

[PATCH v2 11/17] net/i40e: add flow destroy function

> +
> + return ret;
> +}
> +
> +static int
> +i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf,
> +   struct i40e_ethertype_filter *filter)
> +{
> + struct i40e_hw *hw = I40E_PF_TO_HW(pf);
> + struct i40e_ethertype_rule *ethertype_rule = &pf->ethertype;
> + struct i40e_ethertype_filter *node;
> + struct i40e_control_filter_stats stats;
> + uint16_t flags = 0;
> + int ret = 0;
> +
> + if (!(filter->flags & RTE_ETHTYPE_FLAGS_MAC))
> + flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC;
> + if (filter->flags & RTE_ETHTYPE_FLAGS_DROP)
> + flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP;
> + flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TO_QUEUE;
> +
> + memset(&stats, 0, sizeof(stats));
> + ret = i40e_aq_add_rem_control_packet_filter(hw,
> + filter->input.mac_addr.addr_bytes,
> + filter->input.ether_type,
> + flags, pf->main_vsi->seid,
> + filter->queue, 0, &stats, NULL);
> + if (ret < 0)
> + return ret;
> +
> + node = i40e_sw_ethertype_filter_lookup(ethertype_rule, &filter->input);
> + if (node)
> + ret = i40e_sw_ethertype_filter_del(pf, node);
> + else
> + return -EINVAL;

It would be more readable to check whether node equals NULL and return
when it's true, and call i40e_sw_ethertype_filter_del(pf, node) outside
the `if' statement:

node = i40e_sw_ethertype_filter_lookup(ethertype_rule, &filter->input);
if (node == NULL)
return -EINVAL;

ret = i40e_sw_ethertype_filter_del(pf, node);

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2 15/17] net/i40e: add flow flush function

2016-12-27 Thread Tiwei Bie
te_flow_error *error)
> +{
> + struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
> + int ret = 0;
> +

Meaningless initialization.

> + ret = i40e_fdir_filter_flush(pf);
> + if (!ret)
> + rte_flow_error_set(error, EINVAL,
> +RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
> +"Failed to flush FDIR flows.");

Just curious. What's the relationship between `ret' and the code (EINVAL)
passed to rte_flow_error_set()? Is `-ret' acceptable as the parameter?
Because the `-ret' which is actually returned by i40e_fdir_flush() is also
some standard UNIX errno. When error occurs, user should use which one to
figure out the failure reason? `-ret' or `rte_errno'?

> +
> + return ret;
> +}
> +
> +static int
> +i40e_fdir_filter_flush(struct i40e_pf *pf)
> +{
> + struct rte_eth_dev *dev = pf->adapter->eth_dev;
> + struct i40e_fdir_info *fdir_info = &pf->fdir;
> + struct i40e_fdir_filter *fdir_filter;
> + struct i40e_flow *flow;
> + int ret = 0;
> +

Meaningless initialization.

> + ret = i40e_fdir_flush(dev);
> +     if (!ret) {
> + /* Delete FDIR filters in FDIR list. */
> + while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list)))
> + i40e_sw_fdir_filter_del(pf, fdir_filter);
> +

The i40e_sw_fdir_filter_del() may fail, in which case fdir_filter won't
be removed from fdir_info->fdir_list. Will it lead to an infinite loop?
Should you check the retval of i40e_sw_fdir_filter_del() and break the
loop when it fails?

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2 15/17] net/i40e: add flow flush function

2016-12-27 Thread Tiwei Bie
On Wed, Dec 28, 2016 at 02:48:02PM +0800, Xing, Beilei wrote:
> > -Original Message-
> > From: Bie, Tiwei
> > Sent: Wednesday, December 28, 2016 1:36 PM
> > To: Xing, Beilei 
> > Cc: Wu, Jingjing ; Zhang, Helin
> > ; dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v2 15/17] net/i40e: add flow flush function
> > 
> > On Tue, Dec 27, 2016 at 02:26:22PM +0800, Beilei Xing wrote:
> > > This patch adds i40e_flow_flush function to flush all filters for
> > > users. And flow director flush function is involved first.
> > >
> > > Signed-off-by: Beilei Xing 
> > > ---
> > >  drivers/net/i40e/i40e_ethdev.h |  3 +++
> > >  drivers/net/i40e/i40e_fdir.c   |  8 ++--
> > >  drivers/net/i40e/i40e_flow.c   | 46
> > ++
> > >  3 files changed, 51 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/drivers/net/i40e/i40e_ethdev.h
> > > b/drivers/net/i40e/i40e_ethdev.h index b8c7d41..0b736d5 100644
> > > --- a/drivers/net/i40e/i40e_ethdev.h
> > > +++ b/drivers/net/i40e/i40e_ethdev.h
> > > @@ -786,6 +786,9 @@ i40e_sw_tunnel_filter_lookup(struct
> > i40e_tunnel_rule *tunnel_rule,
> > >const struct i40e_tunnel_filter_input *input);  int
> > > i40e_sw_tunnel_filter_del(struct i40e_pf *pf,
> > > struct i40e_tunnel_filter *tunnel_filter);
> > > +int i40e_sw_fdir_filter_del(struct i40e_pf *pf,
> > > + struct i40e_fdir_filter *filter); int
> > i40e_fdir_flush(struct
> > > +rte_eth_dev *dev);
> > >
> > 
> > Why don't declare them as the global functions at the beginning?
> 
> When I implement the store/restore function, I plan this function is only 
> used in i40e_ethdev.c.
> I change them to the global functions since I add i40e_flow.c to rework all  
> the flow ops.
> 

These functions are also introduced in this patch set. There is no
particular reason to mark them as static at first and then turn them
into the global functions in the later patches. So it would be better
to declare them as the global ones when introducing them.

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2 03/17] net/i40e: store flow director filter

2016-12-27 Thread Tiwei Bie
On Wed, Dec 28, 2016 at 03:10:39PM +0800, Xing, Beilei wrote:
> 
> 
> > -Original Message-
> > From: Bie, Tiwei
> > Sent: Wednesday, December 28, 2016 11:39 AM
> > To: Xing, Beilei 
> > Cc: Wu, Jingjing ; Zhang, Helin
> > ; dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v2 03/17] net/i40e: store flow director 
> > filter
> > 
> > On Tue, Dec 27, 2016 at 02:26:10PM +0800, Beilei Xing wrote:
> > > Currently there's no flow director filter stored in SW. This patch
> > > stores flow director filters in SW with cuckoo hash, also adds
> > > protection if a flow director filter has been added.
> > >
> > > Signed-off-by: Beilei Xing 
> > > ---
> > >  drivers/net/i40e/i40e_ethdev.c | 48 +
> > > drivers/net/i40e/i40e_ethdev.h | 12 ++
> > >  drivers/net/i40e/i40e_fdir.c   | 98
> > ++
> > >  3 files changed, 158 insertions(+)
> > >
> > > diff --git a/drivers/net/i40e/i40e_ethdev.c
> > > b/drivers/net/i40e/i40e_ethdev.c index c012d5d..427ebdc 100644
> > > --- a/drivers/net/i40e/i40e_ethdev.c
> > > +++ b/drivers/net/i40e/i40e_ethdev.c
> > [...]
> > > @@ -1342,6 +1379,17 @@ eth_i40e_dev_uninit(struct rte_eth_dev *dev)
> > >   rte_free(p_tunnel);
> > >   }
> > >
> > > + /* Remove all flow director rules and hash */
> > > + if (fdir_info->hash_map)
> > > + rte_free(fdir_info->hash_map);
> > > + if (fdir_info->hash_table)
> > > + rte_hash_free(fdir_info->hash_table);
> > > +
> > > + while ((p_fdir = TAILQ_FIRST(&fdir_info->fdir_list))) {
> > 
> > There is a redundant pair of parentheses, or you should compare with NULL.
> 
> I think the another parentheses is used to compare with NULL. In fact there's 
> similar using in PMD.
> 

The outer parentheses are redundant unless you compare it with NULL explicitly.
Any way, you could just follow the existing coding style.

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v2 03/17] net/i40e: store flow director filter

2016-12-27 Thread Tiwei Bie
On Wed, Dec 28, 2016 at 03:14:55PM +0800, Tiwei Bie wrote:
> On Wed, Dec 28, 2016 at 03:10:39PM +0800, Xing, Beilei wrote:
> > 
> > 
> > > -Original Message-
> > > From: Bie, Tiwei
> > > Sent: Wednesday, December 28, 2016 11:39 AM
> > > To: Xing, Beilei 
> > > Cc: Wu, Jingjing ; Zhang, Helin
> > > ; dev@dpdk.org
> > > Subject: Re: [dpdk-dev] [PATCH v2 03/17] net/i40e: store flow director 
> > > filter
> > > 
> > > On Tue, Dec 27, 2016 at 02:26:10PM +0800, Beilei Xing wrote:
> > > > Currently there's no flow director filter stored in SW. This patch
> > > > stores flow director filters in SW with cuckoo hash, also adds
> > > > protection if a flow director filter has been added.
> > > >
> > > > Signed-off-by: Beilei Xing 
> > > > ---
> > > >  drivers/net/i40e/i40e_ethdev.c | 48 +
> > > > drivers/net/i40e/i40e_ethdev.h | 12 ++
> > > >  drivers/net/i40e/i40e_fdir.c   | 98
> > > ++
> > > >  3 files changed, 158 insertions(+)
> > > >
> > > > diff --git a/drivers/net/i40e/i40e_ethdev.c
> > > > b/drivers/net/i40e/i40e_ethdev.c index c012d5d..427ebdc 100644
> > > > --- a/drivers/net/i40e/i40e_ethdev.c
> > > > +++ b/drivers/net/i40e/i40e_ethdev.c
> > > [...]
> > > > @@ -1342,6 +1379,17 @@ eth_i40e_dev_uninit(struct rte_eth_dev *dev)
> > > > rte_free(p_tunnel);
> > > > }
> > > >
> > > > +   /* Remove all flow director rules and hash */
> > > > +   if (fdir_info->hash_map)
> > > > +   rte_free(fdir_info->hash_map);
> > > > +   if (fdir_info->hash_table)
> > > > +   rte_hash_free(fdir_info->hash_table);
> > > > +
> > > > +   while ((p_fdir = TAILQ_FIRST(&fdir_info->fdir_list))) {
> > > 
> > > There is a redundant pair of parentheses, or you should compare with NULL.
> > 
> > I think the another parentheses is used to compare with NULL. In fact 
> > there's similar using in PMD.
> > 
> 
> The outer parentheses are redundant unless you compare it with NULL 
> explicitly.
> Any way, you could just follow the existing coding style.
> 

Sorry, I was wrong here. I just did a quick check and noticed that DPDK
has enabled the below option:

-Werror=parentheses

The outer parentheses are NOT redundant even if you don't compare it with
NULL explicitly.

Best regards,
Tiwei Bie


[dpdk-dev] [PATCH v4 0/7] Add MACsec offload support for ixgbe

2016-12-28 Thread Tiwei Bie
This patch set adds the MACsec offload support for ixgbe.
The testpmd is also updated to support MACsec cmds.

v2:
- Update the documents for testpmd;
- Update the release notes;
- Reuse the functions provided by base code;

v3:
- Add the missing parts of MACsec mbuf flag and reorganize the patch set;
- Add an ethdev event type for MACsec;
- Advertise the MACsec offload capabilities based on the mac type;
- Minor fixes and improvements;

v4:
- Reserve bits in mbuf and ethdev for PMD specific API;
- Use the reserved bits in PMD specific API;

Tiwei Bie (7):
  mbuf: reserve a Tx offload flag for PMD-specific API
  ethdev: reserve an event type for PMD-specific API
  ethdev: reserve capability flags for PMD-specific API
  net/ixgbe: add MACsec offload support
  app/testpmd: add MACsec offload commands
  doc: add ixgbe specific APIs
  doc: update the release notes for the reserved flags

 app/test-pmd/cmdline.c  | 389 ++
 app/test-pmd/macfwd.c   |   7 +
 app/test-pmd/macswap.c  |   7 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   7 +
 doc/guides/rel_notes/release_17_02.rst  |  18 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 ++
 drivers/net/ixgbe/ixgbe_ethdev.c| 481 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   5 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 122 +++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 lib/librte_ether/rte_ethdev.h   |   4 +
 lib/librte_mbuf/rte_mbuf.c  |   2 +
 lib/librte_mbuf/rte_mbuf.h  |   5 +
 15 files changed, 1132 insertions(+), 5 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH v4 1/7] mbuf: reserve a Tx offload flag for PMD-specific API

2016-12-28 Thread Tiwei Bie
Reserve a Tx offload flag in mbuf, that can be used by PMD to define
its own Tx offload flag when implementing the PMD-specific API.

Suggested-by: Adrien Mazarguil 
Signed-off-by: Tiwei Bie 
---
 lib/librte_mbuf/rte_mbuf.c | 2 ++
 lib/librte_mbuf/rte_mbuf.h | 5 +
 2 files changed, 7 insertions(+)

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 63f43c8..15c4f68 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -404,6 +404,7 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
case PKT_TX_TUNNEL_GRE: return "PKT_TX_TUNNEL_GRE";
case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
+   case PKT_TX_RESERVED_0: return "PKT_TX_RESERVED_0";
default: return NULL;
}
 }
@@ -434,6 +435,7 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t 
buflen)
  "PKT_TX_TUNNEL_NONE" },
{ PKT_TX_TUNNEL_GENEVE, PKT_TX_TUNNEL_MASK,
  "PKT_TX_TUNNEL_NONE" },
+   { PKT_TX_RESERVED_0, PKT_TX_RESERVED_0, NULL },
};
const char *name;
unsigned int i;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ead7c6e..6168a6d 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -182,6 +182,11 @@ extern "C" {
 /* add new TX flags here */
 
 /**
+ * Reserved Tx offload flag for PMD-specific API.
+ */
+#define PKT_TX_RESERVED_0 (0x1ULL << 44)
+
+/**
  * Bits 45:48 used for the tunnel type.
  * When doing Tx offload like TSO or checksum, the HW needs to configure the
  * tunnel type into the HW descriptors.
-- 
2.7.4



[dpdk-dev] [PATCH v4 2/7] ethdev: reserve an event type for PMD-specific API

2016-12-28 Thread Tiwei Bie
Reserve an event type, that can be used by PMD to define its own
event type when implementing the PMD-specific API.

Suggested-by: Adrien Mazarguil 
Signed-off-by: Tiwei Bie 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index fb51754..d465825 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3044,6 +3044,8 @@ enum rte_eth_event_type {
RTE_ETH_EVENT_INTR_RESET,
/**< reset interrupt event, sent to VF on PF reset */
RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
+   RTE_ETH_EVENT_RESERVED_0,
+   /**< reserved event type for PMD-specific API */
RTE_ETH_EVENT_MAX   /**< max value of this enum */
 };
 
-- 
2.7.4



[dpdk-dev] [PATCH v4 3/7] ethdev: reserve capability flags for PMD-specific API

2016-12-28 Thread Tiwei Bie
Reserve a Tx capability flag and a Rx capability flag, that can be
used by PMD to define its own capability flags when implementing the
PMD-specific API.

Suggested-by: Adrien Mazarguil 
Signed-off-by: Tiwei Bie 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d465825..8800b39 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -857,6 +857,7 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_TCP_LRO 0x0010
 #define DEV_RX_OFFLOAD_QINQ_STRIP  0x0020
 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x0040
+#define DEV_RX_OFFLOAD_RESERVED_0  0x0080 /**< Used for PMD-specific API. 
*/
 
 /**
  * TX offload capabilities of a device.
@@ -874,6 +875,7 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_GRE_TNL_TSO  0x0400/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_IPIP_TNL_TSO 0x0800/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO   0x1000/**< Used for tunneling 
packet. */
+#define DEV_TX_OFFLOAD_RESERVED_0  0x2000 /**< Used for PMD-specific API. 
*/
 
 /**
  * Ethernet device information
-- 
2.7.4



[dpdk-dev] [PATCH v4 4/7] net/ixgbe: add MACsec offload support

2016-12-28 Thread Tiwei Bie
MACsec (or LinkSec, 802.1AE) is a MAC level encryption/authentication
scheme defined in IEEE 802.1AE that uses symmetric cryptography.
This commit adds the MACsec offload support for ixgbe.

Signed-off-by: Tiwei Bie 
---
 drivers/net/ixgbe/ixgbe_ethdev.c| 481 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   5 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 122 +++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 5 files changed, 659 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ec2edad..653ddd2 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -231,6 +231,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
uint16_t reta_size);
 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
+static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
@@ -745,6 +746,51 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_stats_strings[] = {
 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
   sizeof(rte_ixgbe_stats_strings[0]))
 
+/* MACsec statistics */
+static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
+   {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_untagged)},
+   {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_encrypted)},
+   {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_protected)},
+   {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_octets_encrypted)},
+   {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
+   out_octets_protected)},
+   {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_untagged)},
+   {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_badtag)},
+   {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_nosci)},
+   {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unknownsci)},
+   {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
+   in_octets_decrypted)},
+   {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
+   in_octets_validated)},
+   {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unchecked)},
+   {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_delayed)},
+   {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_late)},
+   {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_ok)},
+   {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_invalid)},
+   {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notvalid)},
+   {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unusedsa)},
+   {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notusingsa)},
+};
+
+#define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
+  sizeof(rte_ixgbe_macsec_strings[0]))
+
 /* Per-queue statistics */
 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
{"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
@@ -2367,6 +2413,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
/* check if lsc interrupt is enabled */
if (dev->data->dev_conf.intr_conf.lsc != 0)
ixgbe_dev_lsc_interrupt_setup(dev);
+   ixgbe_dev_macsec_interrupt_setup(dev);
} else {
rte_intr_callback_unregister(intr_handle,
 ixgbe_dev_interrupt_handler, dev);
@@ -2557,6 +2604,7 @@ ixgbe_dev_close(struct rte_eth_dev *dev)
 static void
 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
   struct ixgbe_hw_stats *hw_stats,
+  struct ixgbe_macsec_stats *macsec_stats,
   uint64_t *total_missed_rx, uint64_t *total_qbrc,
   uint64_t *total_qprc, uint64_t *total_qprdc)
 {
@@ -2726,6 +2774,40 @@ ixgbe_read_stats_

[dpdk-dev] [PATCH v4 6/7] doc: add ixgbe specific APIs

2016-12-28 Thread Tiwei Bie
Add information about the new ixgbe PMD APIs in the release note.

Signed-off-by: Tiwei Bie 
---
 doc/guides/rel_notes/release_17_02.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 180af82..34dba45 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,12 @@ New Features
   See the :ref:`Generic flow API ` documentation for more
   information.
 
+* **Added APIs for MACsec offload support to the ixgbe PMD.**
+
+  Six new APIs and some related flags have been added to the ixgbe PMD for
+  MACsec offload support. The declarations of the APIs and the definitions
+  of the flags can be found in ``rte_pmd_ixgbe.h``.
+
 
 Resolved Issues
 ---
-- 
2.7.4



[dpdk-dev] [PATCH v4 7/7] doc: update the release notes for the reserved flags

2016-12-28 Thread Tiwei Bie
Add information about the reserved flags for PMD-specific API in
the release note.

Signed-off-by: Tiwei Bie 
---
 doc/guides/rel_notes/release_17_02.rst | 12 
 1 file changed, 12 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 34dba45..af71f39 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -58,6 +58,18 @@ New Features
   MACsec offload support. The declarations of the APIs and the definitions
   of the flags can be found in ``rte_pmd_ixgbe.h``.
 
+* **Reserved flags for PMD to implement the PMD-specific API.**
+
+  Following flags in mbuf and ethdev are reserved for PMD to define its
+  own flags when implementing the PMD-specific API.
+
+  * DEV_RX_OFFLOAD_RESERVED_0
+  * DEV_TX_OFFLOAD_RESERVED_0
+  * RTE_ETH_EVENT_RESERVED_0
+  * PKT_TX_RESERVED_0
+
+  You can refer to ``rte_pmd_ixgbe.h`` for an example.
+
 
 Resolved Issues
 ---
-- 
2.7.4



[dpdk-dev] [PATCH v4 5/7] app/testpmd: add MACsec offload commands

2016-12-28 Thread Tiwei Bie
Below MACsec offload commands are added:

- set macsec offload  on encrypt on|off replay-protect on|off
- set macsec offload  off
- set macsec sc tx|rx   
- set macsec sa tx|rx 

Also update the testpmd user guide.

Signed-off-by: Tiwei Bie 
---
 app/test-pmd/cmdline.c  | 389 
 app/test-pmd/macfwd.c   |   7 +
 app/test-pmd/macswap.c  |   7 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   7 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 +++
 6 files changed, 444 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f768b6b..4a67894 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -275,6 +275,18 @@ static void cmd_help_long_parsed(void *parsed_result,
 
"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
"Set MAC antispoof for a VF from the PF.\n\n"
+
+   "set macsec offload (port_id) on encrypt (on|off) 
replay-protect (on|off)\n"
+   "Enable MACsec offload.\n\n"
+
+   "set macsec offload (port_id) off\n"
+   "Disable MACsec offload.\n\n"
+
+   "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
+   "Configure MACsec secure connection (SC).\n\n"
+
+   "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) 
(key)\n"
+   "Configure MACsec secure association (SA).\n\n"
 #endif
 
"vlan set strip (on|off) (port_id)\n"
@@ -11488,6 +11500,379 @@ cmdline_parse_inst_t cmd_set_vf_mac_addr = {
NULL,
},
 };
+
+/* MACsec configuration */
+
+/* Common result structure for MACsec offload enable */
+struct cmd_macsec_offload_on_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t macsec;
+   cmdline_fixed_string_t offload;
+   uint8_t port_id;
+   cmdline_fixed_string_t on;
+   cmdline_fixed_string_t encrypt;
+   cmdline_fixed_string_t en_on_off;
+   cmdline_fixed_string_t replay_protect;
+   cmdline_fixed_string_t rp_on_off;
+};
+
+/* Common CLI fields for MACsec offload disable */
+cmdline_parse_token_string_t cmd_macsec_offload_on_set =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+set, "set");
+cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+macsec, "macsec");
+cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+offload, "offload");
+cmdline_parse_token_string_t cmd_macsec_offload_on_port_id =
+   TOKEN_NUM_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+port_id, UINT8);
+cmdline_parse_token_string_t cmd_macsec_offload_on_on =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+on, "on");
+cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+encrypt, "encrypt");
+cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+en_on_off, "on#off");
+cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+replay_protect, "replay-protect");
+cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+rp_on_off, "on#off");
+
+static void
+cmd_set_macsec_offload_on_parsed(
+   void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_macsec_offload_on_result *res = parsed_result;
+   int ret;
+   portid_t port_id = res->port_id;
+   int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
+   int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
+
+   if (port_id_is_invalid(port_id, ENABLED_WARN))
+   return;
+
+   ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
+   ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
+
+   switch (ret) {
+   case 0:
+   break;
+   case -ENODEV:
+   printf("invalid port_id %d\n", po

[dpdk-dev] [PATCH v5 0/8] Add MACsec offload support for ixgbe

2017-01-03 Thread Tiwei Bie
This patch set adds the MACsec offload support for ixgbe.
The testpmd is also updated to support MACsec cmds.

v2:
- Update the documents for testpmd;
- Update the release notes;
- Reuse the functions provided by base code;

v3:
- Add the missing parts of MACsec mbuf flag and reorganize the patch set;
- Add an ethdev event type for MACsec;
- Advertise the MACsec offload capabilities based on the mac type;
- Minor fixes and improvements;

v4:
- Reserve bits in mbuf and ethdev for PMD specific API;
- Use the reserved bits in PMD specific API;

v5:
- Add MACsec offload in the NIC feature list;
- Minor improvements on comments;

Tiwei Bie (8):
  mbuf: reserve a Tx offload flag for PMD-specific API
  ethdev: reserve an event type for PMD-specific API
  ethdev: reserve capability flags for PMD-specific API
  net/ixgbe: add MACsec offload support
  app/testpmd: add MACsec offload commands
  doc: add ixgbe specific APIs
  doc: update the release notes for the reserved flags
  doc: add MACsec offload into NIC feature list

 app/test-pmd/cmdline.c  | 389 ++
 app/test-pmd/macfwd.c   |   7 +
 app/test-pmd/macswap.c  |   7 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   7 +
 doc/guides/nics/features/default.ini|   1 +
 doc/guides/nics/features/ixgbe.ini  |   1 +
 doc/guides/rel_notes/release_17_02.rst  |  18 ++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 ++
 drivers/net/ixgbe/ixgbe_ethdev.c| 481 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   5 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 122 +++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 lib/librte_ether/rte_ethdev.h   |   4 +
 lib/librte_mbuf/rte_mbuf.c  |   2 +
 lib/librte_mbuf/rte_mbuf.h  |   5 +
 17 files changed, 1134 insertions(+), 5 deletions(-)

-- 
2.7.4



[dpdk-dev] [PATCH v5 1/8] mbuf: reserve a Tx offload flag for PMD-specific API

2017-01-03 Thread Tiwei Bie
Reserve a Tx offload flag in mbuf, that can be used by PMD to define
its own Tx offload flag when implementing the PMD-specific API.

Suggested-by: Adrien Mazarguil 
Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 lib/librte_mbuf/rte_mbuf.c | 2 ++
 lib/librte_mbuf/rte_mbuf.h | 5 +
 2 files changed, 7 insertions(+)

diff --git a/lib/librte_mbuf/rte_mbuf.c b/lib/librte_mbuf/rte_mbuf.c
index 63f43c8..15c4f68 100644
--- a/lib/librte_mbuf/rte_mbuf.c
+++ b/lib/librte_mbuf/rte_mbuf.c
@@ -404,6 +404,7 @@ const char *rte_get_tx_ol_flag_name(uint64_t mask)
case PKT_TX_TUNNEL_GRE: return "PKT_TX_TUNNEL_GRE";
case PKT_TX_TUNNEL_IPIP: return "PKT_TX_TUNNEL_IPIP";
case PKT_TX_TUNNEL_GENEVE: return "PKT_TX_TUNNEL_GENEVE";
+   case PKT_TX_RESERVED_0: return "PKT_TX_RESERVED_0";
default: return NULL;
}
 }
@@ -434,6 +435,7 @@ rte_get_tx_ol_flag_list(uint64_t mask, char *buf, size_t 
buflen)
  "PKT_TX_TUNNEL_NONE" },
{ PKT_TX_TUNNEL_GENEVE, PKT_TX_TUNNEL_MASK,
  "PKT_TX_TUNNEL_NONE" },
+   { PKT_TX_RESERVED_0, PKT_TX_RESERVED_0, NULL },
};
const char *name;
unsigned int i;
diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h
index ead7c6e..6168a6d 100644
--- a/lib/librte_mbuf/rte_mbuf.h
+++ b/lib/librte_mbuf/rte_mbuf.h
@@ -182,6 +182,11 @@ extern "C" {
 /* add new TX flags here */
 
 /**
+ * Reserved Tx offload flag for PMD-specific API.
+ */
+#define PKT_TX_RESERVED_0 (0x1ULL << 44)
+
+/**
  * Bits 45:48 used for the tunnel type.
  * When doing Tx offload like TSO or checksum, the HW needs to configure the
  * tunnel type into the HW descriptors.
-- 
2.7.4



[dpdk-dev] [PATCH v5 2/8] ethdev: reserve an event type for PMD-specific API

2017-01-03 Thread Tiwei Bie
Reserve an event type, that can be used by PMD to define its own
event type when implementing the PMD-specific API.

Suggested-by: Adrien Mazarguil 
Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index fb51754..d465825 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3044,6 +3044,8 @@ enum rte_eth_event_type {
RTE_ETH_EVENT_INTR_RESET,
/**< reset interrupt event, sent to VF on PF reset */
RTE_ETH_EVENT_VF_MBOX,  /**< message from the VF received by PF */
+   RTE_ETH_EVENT_RESERVED_0,
+   /**< reserved event type for PMD-specific API */
RTE_ETH_EVENT_MAX   /**< max value of this enum */
 };
 
-- 
2.7.4



[dpdk-dev] [PATCH v5 4/8] net/ixgbe: add MACsec offload support

2017-01-03 Thread Tiwei Bie
MACsec (or LinkSec, 802.1AE) is a MAC level encryption/authentication
scheme defined in IEEE 802.1AE that uses symmetric cryptography.
This commit adds the MACsec offload support for ixgbe.

Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 drivers/net/ixgbe/ixgbe_ethdev.c| 481 +++-
 drivers/net/ixgbe/ixgbe_ethdev.h|  45 +++
 drivers/net/ixgbe/ixgbe_rxtx.c  |   5 +
 drivers/net/ixgbe/rte_pmd_ixgbe.h   | 122 +++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  11 +
 5 files changed, 659 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index ec2edad..653ddd2 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -231,6 +231,7 @@ static int ixgbe_dev_rss_reta_query(struct rte_eth_dev *dev,
uint16_t reta_size);
 static void ixgbe_dev_link_status_print(struct rte_eth_dev *dev);
 static int ixgbe_dev_lsc_interrupt_setup(struct rte_eth_dev *dev);
+static int ixgbe_dev_macsec_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_rxq_interrupt_setup(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_get_status(struct rte_eth_dev *dev);
 static int ixgbe_dev_interrupt_action(struct rte_eth_dev *dev,
@@ -745,6 +746,51 @@ static const struct rte_ixgbe_xstats_name_off 
rte_ixgbe_stats_strings[] = {
 #define IXGBE_NB_HW_STATS (sizeof(rte_ixgbe_stats_strings) / \
   sizeof(rte_ixgbe_stats_strings[0]))
 
+/* MACsec statistics */
+static const struct rte_ixgbe_xstats_name_off rte_ixgbe_macsec_strings[] = {
+   {"out_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_untagged)},
+   {"out_pkts_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_encrypted)},
+   {"out_pkts_protected", offsetof(struct ixgbe_macsec_stats,
+   out_pkts_protected)},
+   {"out_octets_encrypted", offsetof(struct ixgbe_macsec_stats,
+   out_octets_encrypted)},
+   {"out_octets_protected", offsetof(struct ixgbe_macsec_stats,
+   out_octets_protected)},
+   {"in_pkts_untagged", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_untagged)},
+   {"in_pkts_badtag", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_badtag)},
+   {"in_pkts_nosci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_nosci)},
+   {"in_pkts_unknownsci", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unknownsci)},
+   {"in_octets_decrypted", offsetof(struct ixgbe_macsec_stats,
+   in_octets_decrypted)},
+   {"in_octets_validated", offsetof(struct ixgbe_macsec_stats,
+   in_octets_validated)},
+   {"in_pkts_unchecked", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unchecked)},
+   {"in_pkts_delayed", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_delayed)},
+   {"in_pkts_late", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_late)},
+   {"in_pkts_ok", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_ok)},
+   {"in_pkts_invalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_invalid)},
+   {"in_pkts_notvalid", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notvalid)},
+   {"in_pkts_unusedsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_unusedsa)},
+   {"in_pkts_notusingsa", offsetof(struct ixgbe_macsec_stats,
+   in_pkts_notusingsa)},
+};
+
+#define IXGBE_NB_MACSEC_STATS (sizeof(rte_ixgbe_macsec_strings) / \
+  sizeof(rte_ixgbe_macsec_strings[0]))
+
 /* Per-queue statistics */
 static const struct rte_ixgbe_xstats_name_off rte_ixgbe_rxq_strings[] = {
{"mbuf_allocation_errors", offsetof(struct ixgbe_hw_stats, rnbc)},
@@ -2367,6 +2413,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev)
/* check if lsc interrupt is enabled */
if (dev->data->dev_conf.intr_conf.lsc != 0)
ixgbe_dev_lsc_interrupt_setup(dev);
+   ixgbe_dev_macsec_interrupt_setup(dev);
} else {
rte_intr_callback_unregister(intr_handle,
 ixgbe_dev_interrupt_handler, dev);
@@ -2557,6 +2604,7 @@ ixgbe_dev_close(struct rte_eth_dev *dev)
 static void
 ixgbe_read_stats_registers(struct ixgbe_hw *hw,
   struct ixgbe_hw_stats *hw_stats,
+  struct ixgbe_macsec_stats *macsec_stats,
   uint64_t *total_missed_rx, uint64_t *total_qbrc,
   uint64_t *total_qprc, uint64_t *total_qprdc)
 {
@@ -2726,6 +2774,40 @@ i

[dpdk-dev] [PATCH v5 3/8] ethdev: reserve capability flags for PMD-specific API

2017-01-03 Thread Tiwei Bie
Reserve a Tx capability flag and a Rx capability flag, that can be
used by PMD to define its own capability flags when implementing the
PMD-specific API.

Suggested-by: Adrien Mazarguil 
Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 lib/librte_ether/rte_ethdev.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index d465825..8800b39 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -857,6 +857,7 @@ struct rte_eth_conf {
 #define DEV_RX_OFFLOAD_TCP_LRO 0x0010
 #define DEV_RX_OFFLOAD_QINQ_STRIP  0x0020
 #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x0040
+#define DEV_RX_OFFLOAD_RESERVED_0  0x0080 /**< Used for PMD-specific API. 
*/
 
 /**
  * TX offload capabilities of a device.
@@ -874,6 +875,7 @@ struct rte_eth_conf {
 #define DEV_TX_OFFLOAD_GRE_TNL_TSO  0x0400/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_IPIP_TNL_TSO 0x0800/**< Used for tunneling 
packet. */
 #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO   0x1000/**< Used for tunneling 
packet. */
+#define DEV_TX_OFFLOAD_RESERVED_0  0x2000 /**< Used for PMD-specific API. 
*/
 
 /**
  * Ethernet device information
-- 
2.7.4



[dpdk-dev] [PATCH v5 5/8] app/testpmd: add MACsec offload commands

2017-01-03 Thread Tiwei Bie
Below MACsec offload commands are added:

- set macsec offload  on encrypt on|off replay-protect on|off
- set macsec offload  off
- set macsec sc tx|rx   
- set macsec sa tx|rx 

Also update the testpmd user guide.

Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 app/test-pmd/cmdline.c  | 389 
 app/test-pmd/macfwd.c   |   7 +
 app/test-pmd/macswap.c  |   7 +
 app/test-pmd/testpmd.h  |   2 +
 app/test-pmd/txonly.c   |   7 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  32 +++
 6 files changed, 444 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index f768b6b..4a67894 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -275,6 +275,18 @@ static void cmd_help_long_parsed(void *parsed_result,
 
"set vf mac antispoof (port_id) (vf_id) (on|off).\n"
"Set MAC antispoof for a VF from the PF.\n\n"
+
+   "set macsec offload (port_id) on encrypt (on|off) 
replay-protect (on|off)\n"
+   "Enable MACsec offload.\n\n"
+
+   "set macsec offload (port_id) off\n"
+   "Disable MACsec offload.\n\n"
+
+   "set macsec sc (tx|rx) (port_id) (mac) (pi)\n"
+   "Configure MACsec secure connection (SC).\n\n"
+
+   "set macsec sa (tx|rx) (port_id) (idx) (an) (pn) 
(key)\n"
+   "Configure MACsec secure association (SA).\n\n"
 #endif
 
"vlan set strip (on|off) (port_id)\n"
@@ -11488,6 +11500,379 @@ cmdline_parse_inst_t cmd_set_vf_mac_addr = {
NULL,
},
 };
+
+/* MACsec configuration */
+
+/* Common result structure for MACsec offload enable */
+struct cmd_macsec_offload_on_result {
+   cmdline_fixed_string_t set;
+   cmdline_fixed_string_t macsec;
+   cmdline_fixed_string_t offload;
+   uint8_t port_id;
+   cmdline_fixed_string_t on;
+   cmdline_fixed_string_t encrypt;
+   cmdline_fixed_string_t en_on_off;
+   cmdline_fixed_string_t replay_protect;
+   cmdline_fixed_string_t rp_on_off;
+};
+
+/* Common CLI fields for MACsec offload disable */
+cmdline_parse_token_string_t cmd_macsec_offload_on_set =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+set, "set");
+cmdline_parse_token_string_t cmd_macsec_offload_on_macsec =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+macsec, "macsec");
+cmdline_parse_token_string_t cmd_macsec_offload_on_offload =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+offload, "offload");
+cmdline_parse_token_string_t cmd_macsec_offload_on_port_id =
+   TOKEN_NUM_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+port_id, UINT8);
+cmdline_parse_token_string_t cmd_macsec_offload_on_on =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+on, "on");
+cmdline_parse_token_string_t cmd_macsec_offload_on_encrypt =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+encrypt, "encrypt");
+cmdline_parse_token_string_t cmd_macsec_offload_on_en_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+en_on_off, "on#off");
+cmdline_parse_token_string_t cmd_macsec_offload_on_replay_protect =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+replay_protect, "replay-protect");
+cmdline_parse_token_string_t cmd_macsec_offload_on_rp_on_off =
+   TOKEN_STRING_INITIALIZER
+   (struct cmd_macsec_offload_on_result,
+rp_on_off, "on#off");
+
+static void
+cmd_set_macsec_offload_on_parsed(
+   void *parsed_result,
+   __attribute__((unused)) struct cmdline *cl,
+   __attribute__((unused)) void *data)
+{
+   struct cmd_macsec_offload_on_result *res = parsed_result;
+   int ret;
+   portid_t port_id = res->port_id;
+   int en = (strcmp(res->en_on_off, "on") == 0) ? 1 : 0;
+   int rp = (strcmp(res->rp_on_off, "on") == 0) ? 1 : 0;
+
+   if (port_id_is_invalid(port_id, ENABLED_WARN))
+   return;
+
+   ports[port_id].tx_ol_flags |= TESTPMD_TX_OFFLOAD_MACSEC;
+   ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
+
+   switch (ret) {
+   case 0:
+   break;
+   case -ENODEV:
+   printf(&

[dpdk-dev] [PATCH v5 6/8] doc: add ixgbe specific APIs

2017-01-03 Thread Tiwei Bie
Add information about the new ixgbe PMD APIs in the release notes.

Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 doc/guides/rel_notes/release_17_02.rst | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 180af82..34dba45 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -52,6 +52,12 @@ New Features
   See the :ref:`Generic flow API ` documentation for more
   information.
 
+* **Added APIs for MACsec offload support to the ixgbe PMD.**
+
+  Six new APIs and some related flags have been added to the ixgbe PMD for
+  MACsec offload support. The declarations of the APIs and the definitions
+  of the flags can be found in ``rte_pmd_ixgbe.h``.
+
 
 Resolved Issues
 ---
-- 
2.7.4



[dpdk-dev] [PATCH v5 7/8] doc: update the release notes for the reserved flags

2017-01-03 Thread Tiwei Bie
Add information about the flags reserved for PMD-specific API in
the release notes.

Signed-off-by: Tiwei Bie 
Acked-by: Wenzhuo Lu 
---
 doc/guides/rel_notes/release_17_02.rst | 12 
 1 file changed, 12 insertions(+)

diff --git a/doc/guides/rel_notes/release_17_02.rst 
b/doc/guides/rel_notes/release_17_02.rst
index 34dba45..af71f39 100644
--- a/doc/guides/rel_notes/release_17_02.rst
+++ b/doc/guides/rel_notes/release_17_02.rst
@@ -58,6 +58,18 @@ New Features
   MACsec offload support. The declarations of the APIs and the definitions
   of the flags can be found in ``rte_pmd_ixgbe.h``.
 
+* **Reserved flags for PMD to implement the PMD-specific API.**
+
+  Following flags in mbuf and ethdev are reserved for PMD to define its
+  own flags when implementing the PMD-specific API.
+
+  * DEV_RX_OFFLOAD_RESERVED_0
+  * DEV_TX_OFFLOAD_RESERVED_0
+  * RTE_ETH_EVENT_RESERVED_0
+  * PKT_TX_RESERVED_0
+
+  You can refer to ``rte_pmd_ixgbe.h`` for an example.
+
 
 Resolved Issues
 ---
-- 
2.7.4



[dpdk-dev] [PATCH v5 8/8] doc: add MACsec offload into NIC feature list

2017-01-03 Thread Tiwei Bie
Add MACsec offload into NIC feature list. And also update the
feature list for the supported drivers.

Signed-off-by: Tiwei Bie 
---
 doc/guides/nics/features/default.ini | 1 +
 doc/guides/nics/features/ixgbe.ini   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/doc/guides/nics/features/default.ini 
b/doc/guides/nics/features/default.ini
index f1bf9bf..c412d6f 100644
--- a/doc/guides/nics/features/default.ini
+++ b/doc/guides/nics/features/default.ini
@@ -43,6 +43,7 @@ VLAN offload =
 QinQ offload =
 L3 checksum offload  =
 L4 checksum offload  =
+MACsec offload   =
 Inner L3 checksum=
 Inner L4 checksum=
 Packet type parsing  =
diff --git a/doc/guides/nics/features/ixgbe.ini 
b/doc/guides/nics/features/ixgbe.ini
index 4a5667f..24c02fb 100644
--- a/doc/guides/nics/features/ixgbe.ini
+++ b/doc/guides/nics/features/ixgbe.ini
@@ -36,6 +36,7 @@ VLAN offload = Y
 QinQ offload = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
+MACsec offload   = Y
 Inner L3 checksum= Y
 Inner L4 checksum= Y
 Packet type parsing  = Y
-- 
2.7.4



Re: [dpdk-dev] [PATCH v2 14/29] eal/arm64: change barrier definitions to macros

2017-01-04 Thread Tiwei Bie
On Wed, Jan 04, 2017 at 03:39:14PM +0530, Jerin Jacob wrote:
> On Tue, Jan 03, 2017 at 03:55:45PM +0800, Jianbo Liu wrote:
> > On 27 December 2016 at 17:49, Jerin Jacob
> >  wrote:
> > > Change rte_?wb definitions to macros in order to
> > 
> > use rte_*mb?
> 
> IMHO, regex ? is appropriate here.
> https://en.wikipedia.org/wiki/Regular_expression
> 

The APIs you're changing are:

> +#define rte_mb() dsb(sy)
> +#define rte_wmb() dsb(st)
> +#define rte_rmb() dsb(ld)

If it's a regex, shouldn't it be: rte_[wr]?mb or rte_.?mb

If ? is a wildcard used by shell, it should at least be: rte_?mb
But rte_*mb is easier to recognize, and matches all of them. :-)

Best regards,
Tiwei Bie

> > 
> > > keep consistent with other barrier definitions in
> > > the file.
> > >
> > > Suggested-by: Jianbo Liu 
> > > Signed-off-by: Jerin Jacob 
> > > ---
> > >  .../common/include/arch/arm/rte_atomic_64.h| 36 
> > > ++
> > >  1 file changed, 3 insertions(+), 33 deletions(-)
> > >
> > > diff --git a/lib/librte_eal/common/include/arch/arm/rte_atomic_64.h 
> > > b/lib/librte_eal/common/include/arch/arm/rte_atomic_64.h
> > > index ef0efc7..dc3a0f3 100644
> > > --- a/lib/librte_eal/common/include/arch/arm/rte_atomic_64.h
> > > +++ b/lib/librte_eal/common/include/arch/arm/rte_atomic_64.h
> > > @@ -46,41 +46,11 @@ extern "C" {
> > >  #define dsb(opt)  { asm volatile("dsb " #opt : : : "memory"); }
> > >  #define dmb(opt)  { asm volatile("dmb " #opt : : : "memory"); }
> > >
> > > -/**
> > > - * General memory barrier.
> > > - *
> > > - * Guarantees that the LOAD and STORE operations generated before the
> > > - * barrier occur before the LOAD and STORE operations generated after.
> > > - * This function is architecture dependent.
> > > - */
> > > -static inline void rte_mb(void)
> > > -{
> > > -   dsb(sy);
> > > -}
> > > +#define rte_mb() dsb(sy)
> > >
> > > -/**
> > > - * Write memory barrier.
> > > - *
> > > - * Guarantees that the STORE operations generated before the barrier
> > > - * occur before the STORE operations generated after.
> > > - * This function is architecture dependent.
> > > - */
> > > -static inline void rte_wmb(void)
> > > -{
> > > -   dsb(st);
> > > -}
> > > +#define rte_wmb() dsb(st)
> > >
> > > -/**
> > > - * Read memory barrier.
> > > - *
> > > - * Guarantees that the LOAD operations generated before the barrier
> > > - * occur before the LOAD operations generated after.
> > > - * This function is architecture dependent.
> > > - */
> > 
> > How about keep the comments for all these macros?
> 
> lib/librte_eal/common/include/generic/rte_atomic.h file has description
> for all the barriers.All other arch are doing in the same-way.
> 
> > 
> > > -static inline void rte_rmb(void)
> > > -{
> > > -   dsb(ld);
> > > -}
> > > +#define rte_rmb() dsb(ld)
> > >
> > >  #define rte_smp_mb() dmb(ish)
> > >
> > > --
> > > 2.5.5
> > >


Re: [dpdk-dev] [PATCH v2 23/29] net/i40e: use eal I/O device memory read/write API

2017-01-04 Thread Tiwei Bie
On Tue, Dec 27, 2016 at 03:19:29PM +0530, Jerin Jacob wrote:
> From: Santosh Shukla 
> 
> Replace the raw I/O device memory read/write access with eal abstraction
> for I/O device memory read/write access to fix portability issues across
> different architectures.
> 
[...]
> diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
> index 7ae7d9f..5c41a90 100644
> --- a/drivers/net/i40e/i40e_rxtx.c
> +++ b/drivers/net/i40e/i40e_rxtx.c
> @@ -1228,7 +1228,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf 
> **tx_pkts, uint16_t nb_pkts)
>  (unsigned) txq->port_id, (unsigned) txq->queue_id,
>  (unsigned) tx_id, (unsigned) nb_tx);
>  
> - I40E_PCI_REG_WRITE(txq->qtx_tail, tx_id);
> + I40E_PCI_REG_WRITE_RELAXED(txq->qtx_tail, tx_id);
>   txq->tx_tail = tx_id;
>  
>   return nb_tx;
> @@ -1380,7 +1380,7 @@ tx_xmit_pkts(struct i40e_tx_queue *txq,
>  
>   /* Update the tx tail register */
>   rte_wmb();
> - I40E_PCI_REG_WRITE(txq->qtx_tail, txq->tx_tail);
> + I40E_PCI_REG_WRITE_RELAXED(txq->qtx_tail, txq->tx_tail);
>  
>   return nb_pkts;
>  }

Besides i40e_xmit_pkts() and tx_xmit_pkts(), i40e_rx_alloc_bufs() which is
called by rx_recv_pkts() is also in the fast path. So I40E_PCI_REG_WRITE()
called by it should also be replaced by the relaxed version:

diff --git i/drivers/net/i40e/i40e_rxtx.c w/drivers/net/i40e/i40e_rxtx.c
index 7ae7d9f..55a707a 100644
--- i/drivers/net/i40e/i40e_rxtx.c
+++ w/drivers/net/i40e/i40e_rxtx.c
@@ -581,7 +581,7 @@ i40e_rx_alloc_bufs(struct i40e_rx_queue *rxq)
 
/* Update rx tail regsiter */
rte_wmb();
-   I40E_PCI_REG_WRITE(rxq->qrx_tail, rxq->rx_free_trigger);
+   I40E_PCI_REG_WRITE_RELAXED(rxq->qrx_tail, rxq->rx_free_trigger);
 
        rxq->rx_free_trigger =
(uint16_t)(rxq->rx_free_trigger + rxq->rx_free_thresh);

Thanks & regards,
Tiwei Bie

> -- 
> 2.5.5
> 


Re: [dpdk-dev] [PATCH v5 3/8] ethdev: reserve capability flags for PMD-specific API

2017-01-04 Thread Tiwei Bie
On Wed, Jan 04, 2017 at 10:21:08PM +0800, Ananyev, Konstantin wrote:
> Hi Twei,
> 
> > -Original Message-
> > From: Bie, Tiwei
> > Sent: Wednesday, January 4, 2017 7:22 AM
> > To: dev@dpdk.org
> > Cc: adrien.mazarg...@6wind.com; Lu, Wenzhuo ; 
> > Mcnamara, John ;
> > olivier.m...@6wind.com; thomas.monja...@6wind.com; Ananyev, Konstantin 
> > ; Zhang, Helin
> > ; Dai, Wei ; Wang, Xiao W 
> > 
> > Subject: [PATCH v5 3/8] ethdev: reserve capability flags for PMD-specific 
> > API
> > 
> > Reserve a Tx capability flag and a Rx capability flag, that can be
> > used by PMD to define its own capability flags when implementing the
> > PMD-specific API.
> > 
> > Suggested-by: Adrien Mazarguil 
> > Signed-off-by: Tiwei Bie 
> > Acked-by: Wenzhuo Lu 
> > ---
> >  lib/librte_ether/rte_ethdev.h | 2 ++
> >  1 file changed, 2 insertions(+)
> > 
> > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
> > index d465825..8800b39 100644
> > --- a/lib/librte_ether/rte_ethdev.h
> > +++ b/lib/librte_ether/rte_ethdev.h
> > @@ -857,6 +857,7 @@ struct rte_eth_conf {
> >  #define DEV_RX_OFFLOAD_TCP_LRO 0x0010
> >  #define DEV_RX_OFFLOAD_QINQ_STRIP  0x0020
> >  #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x0040
> > +#define DEV_RX_OFFLOAD_RESERVED_0  0x0080 /**< Used for PMD-specific 
> > API. */
> > 
> >  /**
> >   * TX offload capabilities of a device.
> > @@ -874,6 +875,7 @@ struct rte_eth_conf {
> >  #define DEV_TX_OFFLOAD_GRE_TNL_TSO  0x0400/**< Used for 
> > tunneling packet. */
> >  #define DEV_TX_OFFLOAD_IPIP_TNL_TSO 0x0800/**< Used for 
> > tunneling packet. */
> >  #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO   0x1000/**< Used for 
> > tunneling packet. */
> > +#define DEV_TX_OFFLOAD_RESERVED_0  0x2000 /**< Used for PMD-specific 
> > API. */
> > 
> >  /**
> >   * Ethernet device information
> > --
> > 2.7.4
> 
> I am not sure how that supposed to work and how user should know that 
> DEV_RX_OFFLOAD_RESERVED_0  
> is actually a MACSEC for ixgbe?

Users are not supposed to use DEV_RX_OFFLOAD_RESERVED_0, instead, they
should use the capabilities and the likes defined in rte_pmd_ixgbe.h
where the PMD-specifics APIs are declared:

/**
 * If these flags are advertised by the PMD, the NIC supports the MACsec
 * offload. The incoming MACsec traffics can be offloaded transparently
 * after the MACsec offload is configured correctly by the application.
 * And the application can set the PKT_TX_IXGBE_MACSEC flag in mbufs to
 * enable the MACsec offload for the packets to be transmitted.
 */
#define DEV_RX_OFFLOAD_IXGBE_MACSEC_STRIP   DEV_RX_OFFLOAD_RESERVED_0
#define DEV_TX_OFFLOAD_IXGBE_MACSEC_INSERT  DEV_TX_OFFLOAD_RESERVED_0

/**
 * This event will occur when the PN counter in a MACsec connection
 * reach the exhaustion threshold.
 */
#define RTE_ETH_EVENT_IXGBE_MACSEC  RTE_ETH_EVENT_RESERVED_0

/**
 * Offload the MACsec. This flag must be set by the application in mbuf
 * to enable this offload feature for a packet to be transmitted.
 */
#define PKT_TX_IXGBE_MACSEC PKT_TX_RESERVED_0

PMD-specific APIs can only be used on the corresponding driver/device,
so different PMD can share the same reserved bit to represent different
things when implementing their own PMD-specific APIs.

> Another question what to do if you would like to create a bonded device over 
> two devices with different NIC types?
> As I understand you can end up in situation when  DEV_RX_OFFLOAD_RESERVED_0  
> would mean different capabilities.
> Why not to have this MACSEC capability and ol_flag value as generic ones, as 
> you have them in previous versions of your patch?

Those flags are only used in PMD-specific APIs. I don't think we could
use the PMD-specific APIs provided by a certain PMD on a bonded device.

Thanks & regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v5 3/8] ethdev: reserve capability flags for PMD-specific API

2017-01-04 Thread Tiwei Bie
On Wed, Jan 04, 2017 at 11:14:25PM +0800, Ananyev, Konstantin wrote:
> 
> 
> > -Original Message-
> > From: Bie, Tiwei
> > Sent: Wednesday, January 4, 2017 2:39 PM
> > To: Ananyev, Konstantin 
> > Cc: dev@dpdk.org; adrien.mazarg...@6wind.com; Lu, Wenzhuo 
> > ; Mcnamara, John ;
> > olivier.m...@6wind.com; thomas.monja...@6wind.com; Zhang, Helin 
> > ; Dai, Wei ; Wang,
> > Xiao W 
> > Subject: Re: [PATCH v5 3/8] ethdev: reserve capability flags for 
> > PMD-specific API
> > 
> > On Wed, Jan 04, 2017 at 10:21:08PM +0800, Ananyev, Konstantin wrote:
> > > Hi Twei,
> > >
> > > > -Original Message-
> > > > From: Bie, Tiwei
> > > > Sent: Wednesday, January 4, 2017 7:22 AM
> > > > To: dev@dpdk.org
> > > > Cc: adrien.mazarg...@6wind.com; Lu, Wenzhuo ; 
> > > > Mcnamara, John ;
> > > > olivier.m...@6wind.com; thomas.monja...@6wind.com; Ananyev, Konstantin 
> > > > ; Zhang, Helin
> > > > ; Dai, Wei ; Wang, Xiao W 
> > > > 
> > > > Subject: [PATCH v5 3/8] ethdev: reserve capability flags for 
> > > > PMD-specific API
> > > >
> > > > Reserve a Tx capability flag and a Rx capability flag, that can be
> > > > used by PMD to define its own capability flags when implementing the
> > > > PMD-specific API.
> > > >
> > > > Suggested-by: Adrien Mazarguil 
> > > > Signed-off-by: Tiwei Bie 
> > > > Acked-by: Wenzhuo Lu 
> > > > ---
> > > >  lib/librte_ether/rte_ethdev.h | 2 ++
> > > >  1 file changed, 2 insertions(+)
> > > >
> > > > diff --git a/lib/librte_ether/rte_ethdev.h 
> > > > b/lib/librte_ether/rte_ethdev.h
> > > > index d465825..8800b39 100644
> > > > --- a/lib/librte_ether/rte_ethdev.h
> > > > +++ b/lib/librte_ether/rte_ethdev.h
> > > > @@ -857,6 +857,7 @@ struct rte_eth_conf {
> > > >  #define DEV_RX_OFFLOAD_TCP_LRO 0x0010
> > > >  #define DEV_RX_OFFLOAD_QINQ_STRIP  0x0020
> > > >  #define DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM 0x0040
> > > > +#define DEV_RX_OFFLOAD_RESERVED_0  0x0080 /**< Used for 
> > > > PMD-specific API. */
> > > >
> > > >  /**
> > > >   * TX offload capabilities of a device.
> > > > @@ -874,6 +875,7 @@ struct rte_eth_conf {
> > > >  #define DEV_TX_OFFLOAD_GRE_TNL_TSO  0x0400/**< Used for 
> > > > tunneling packet. */
> > > >  #define DEV_TX_OFFLOAD_IPIP_TNL_TSO 0x0800/**< Used for 
> > > > tunneling packet. */
> > > >  #define DEV_TX_OFFLOAD_GENEVE_TNL_TSO   0x1000/**< Used for 
> > > > tunneling packet. */
> > > > +#define DEV_TX_OFFLOAD_RESERVED_0  0x2000 /**< Used for 
> > > > PMD-specific API. */
> > > >
> > > >  /**
> > > >   * Ethernet device information
> > > > --
> > > > 2.7.4
> > >
> > > I am not sure how that supposed to work and how user should know that 
> > > DEV_RX_OFFLOAD_RESERVED_0
> > > is actually a MACSEC for ixgbe?
> > 
> > Users are not supposed to use DEV_RX_OFFLOAD_RESERVED_0, instead, they
> > should use the capabilities and the likes defined in rte_pmd_ixgbe.h
> > where the PMD-specifics APIs are declared:
> > 
> > /**
> >  * If these flags are advertised by the PMD, the NIC supports the MACsec
> >  * offload. The incoming MACsec traffics can be offloaded transparently
> >  * after the MACsec offload is configured correctly by the application.
> >  * And the application can set the PKT_TX_IXGBE_MACSEC flag in mbufs to
> >  * enable the MACsec offload for the packets to be transmitted.
> >  */
> > #define DEV_RX_OFFLOAD_IXGBE_MACSEC_STRIP   DEV_RX_OFFLOAD_RESERVED_0
> > #define DEV_TX_OFFLOAD_IXGBE_MACSEC_INSERT  DEV_TX_OFFLOAD_RESERVED_0
> > 
> > /**
> >  * This event will occur when the PN counter in a MACsec connection
> >  * reach the exhaustion threshold.
> >  */
> > #define RTE_ETH_EVENT_IXGBE_MACSEC  RTE_ETH_EVENT_RESERVED_0
> > 
> > /**
> >  * Offload the MACsec. This flag must be set by the application in mbuf
> >  * to enable this offload feature for a packet to be transmitted.
> >  */
> > #define PKT_TX_IXGBE_MACSEC PKT_TX_RESERVED_0
> > 
> > PMD-specific APIs can only be used on the corresponding driver/device,
> > so different PMD c

Re: [dpdk-dev] [PATCH v5 3/8] ethdev: reserve capability flags for PMD-specific API

2017-01-04 Thread Tiwei Bie
On Thu, Jan 05, 2017 at 01:44:18AM +0800, Ananyev, Konstantin wrote:
[...]
> > >
> > > I understand that.
> > > My question was: suppose user would like to create a bonded device over 2 
> > > NICs.
> > > One of them is ixgbe, while other would be some other type.
> > > In future get_dev_info() for each of them might return 
> > > DEV_RX_OFFLOAD_RESERVED_0  bit as set.
> > > But it would mean completely different thing.
> > > How bonded device would know that to deal properly?
> > >
> > > Another example - user has 2 NICs of different type and would like to 
> > > send the same packet on both of them simultaneously.
> > > As PKT_TX_RESERVED might mean different things for these devices, and 
> > > user would like to use let say
> > > PKT_TX_IXGBE_MACSEC on one of them, he would need to do a copy of them, 
> > > instead just increment a refcnt.
> > >
> > > Similar issues might arise at RX handling: user got a packet with 
> > > PKT_RX_RESERVED_0 set.
> > > What does it really mean if there are different NIC types in the system?
> > > The only way to answer that question, as I can see,  is to keep track 
> > > from what NIC that packet was received.
> > > Which I suppose, is not always convenient.
> > >
> > 
> > The main purpose is to put the PMD-specific APIs in a separate
> > namespace instead of mixing the PMD-specific APIs and global APIs
> > up, and also save the bits in mbuf.ol_flags.
> > 
> > There are other ways to achieve this goal, such as introducing
> > the PMD specific ol_flags in mbuf second cache line as you said.
> > I just thought defining some reserved bits seems to be the most
> > simple way which won't introduce many changes.
> > 
> > What's your suggestions? Should I just revert the changes and
> > define the generic flags directly?
> 
> Yes, that would be my preference.
> As I said above - spending extra bit in ol_flags  doesn't look like a big 
> problem to me.
> In return there would be no need to consider how to handle all that confusing 
> scenarios in future.

Okay. I'll update my patches. Thanks a lot for your comments.

Thanks & regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH v5 3/8] ethdev: reserve capability flags for PMD-specific API

2017-01-05 Thread Tiwei Bie
On Thu, Jan 05, 2017 at 09:33:22AM +0100, Adrien Mazarguil wrote:
> On Thu, Jan 05, 2017 at 07:56:08AM +0800, Tiwei Bie wrote:
> > On Thu, Jan 05, 2017 at 01:44:18AM +0800, Ananyev, Konstantin wrote:
> > [...]
> > > > >
> > > > > I understand that.
> > > > > My question was: suppose user would like to create a bonded device 
> > > > > over 2 NICs.
> > > > > One of them is ixgbe, while other would be some other type.
> > > > > In future get_dev_info() for each of them might return 
> > > > > DEV_RX_OFFLOAD_RESERVED_0  bit as set.
> > > > > But it would mean completely different thing.
> > > > > How bonded device would know that to deal properly?
> > > > >
> > > > > Another example - user has 2 NICs of different type and would like to 
> > > > > send the same packet on both of them simultaneously.
> > > > > As PKT_TX_RESERVED might mean different things for these devices, and 
> > > > > user would like to use let say
> > > > > PKT_TX_IXGBE_MACSEC on one of them, he would need to do a copy of 
> > > > > them, instead just increment a refcnt.
> > > > >
> > > > > Similar issues might arise at RX handling: user got a packet with 
> > > > > PKT_RX_RESERVED_0 set.
> > > > > What does it really mean if there are different NIC types in the 
> > > > > system?
> > > > > The only way to answer that question, as I can see,  is to keep track 
> > > > > from what NIC that packet was received.
> > > > > Which I suppose, is not always convenient.
> > > > >
> > > > 
> > > > The main purpose is to put the PMD-specific APIs in a separate
> > > > namespace instead of mixing the PMD-specific APIs and global APIs
> > > > up, and also save the bits in mbuf.ol_flags.
> > > > 
> > > > There are other ways to achieve this goal, such as introducing
> > > > the PMD specific ol_flags in mbuf second cache line as you said.
> > > > I just thought defining some reserved bits seems to be the most
> > > > simple way which won't introduce many changes.
> > > > 
> > > > What's your suggestions? Should I just revert the changes and
> > > > define the generic flags directly?
> > > 
> > > Yes, that would be my preference.
> > > As I said above - spending extra bit in ol_flags  doesn't look like a big 
> > > problem to me.
> > > In return there would be no need to consider how to handle all that 
> > > confusing scenarios in future.
> > 
> > Okay. I'll update my patches. Thanks a lot for your comments.
> 
> Well, I do not agree with Konstantin (no one saw this coming eh?) and do not
> think you need to update your series again.
> 

Hi Adrien,

Thank you very much! :-)

Hi Thomas and Olivier,

I don't have strong opinions here, although I prefer to put
the PMD-specific APIs in a separate namespace. I'd like to
hear or follow your opinions since you are the maintainers
of ethdev and mbuf.

Best regards,
Tiwei Bie

> PMD-specific symbols have nothing to do in the global namespace in my
> opinion, they are not versioned and may evolve without notice. Neither
> applications nor the bonding PMD can rely on them. That's the trade-off.
> 
> Therefore until APIs are made global, the safe compromise is to define
> neutral, reserved symbols that any PMD can use to implement their own
> temporary APIs for testing purposes. These can be renamed later without
> changing their value as long as a single PMD uses them.
> 
> -- 
> Adrien Mazarguil
> 6WIND


Re: [dpdk-dev] DPDK & github

2017-07-05 Thread Tiwei Bie
On Wed, Jul 05, 2017 at 11:48:20PM +0200, Thomas Monjalon wrote:
> Hi,
> 
> Following community requests, the Linux Foundation tried to get
> the ownership of the DPDK account on GitHub which was owned
> by someone.
> Good news, it worked:
>   https://github.com/dpdk
> Thanks Trishan for the help.
> 
> First of all, it is not planned to use GitHub and its pull request model,
> as the main repository. It should be a read-only mirror.
> 
> If a pull request is created for https://github.com/dpdk/dpdk,
> we should redirect to the mailing list as Linux do with a bot:
>   https://github.com/ajdlinux/KernelPRBot/blob/master/message.md
> 
> We can discuss how to organize this account for related projects or
> for user repositories. Other ideas are welcome.
> 
> Anticipating the discussion about a bug tracker, it was decided to use
> Bugzilla and configure a workflow friendly with the mailing list.
> As it is not available yet, we can also compare Bugzilla and GitHub.
> 
> Configuring the account for our needs may take time, especially during
> a release period.
> Thanks for your patience.

Great news! Thank you! :-)

Best regards,
Tiwei Bie


[dpdk-dev] [PATCH] net/i40e: remove an unnecessary goto

2017-07-16 Thread Tiwei Bie
Signed-off-by: Tiwei Bie 
---
 drivers/net/i40e/i40e_tm.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/i40e/i40e_tm.c b/drivers/net/i40e/i40e_tm.c
index 56013b1..d90313a 100644
--- a/drivers/net/i40e/i40e_tm.c
+++ b/drivers/net/i40e/i40e_tm.c
@@ -962,8 +962,6 @@ i40e_hierarchy_commit(struct rte_eth_dev *dev,
goto fail_clear;
}
 
-   goto done;
-
 done:
pf->tm_conf.committed = true;
return 0;
-- 
2.7.4



[dpdk-dev] [PATCH] net/ixgbe: remove an unnecessary goto

2017-07-16 Thread Tiwei Bie
Signed-off-by: Tiwei Bie 
---
 drivers/net/ixgbe/ixgbe_tm.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_tm.c b/drivers/net/ixgbe/ixgbe_tm.c
index b76d186..cdcf45c 100644
--- a/drivers/net/ixgbe/ixgbe_tm.c
+++ b/drivers/net/ixgbe/ixgbe_tm.c
@@ -1029,8 +1029,6 @@ ixgbe_hierarchy_commit(struct rte_eth_dev *dev,
}
}
 
-   goto done;
-
 done:
tm_conf->committed = true;
return 0;
-- 
2.7.4



[dpdk-dev] [PATCH] net/virtio: fix coding style

2017-07-16 Thread Tiwei Bie
Make the code more readable. No functional change.

Signed-off-by: Tiwei Bie 
---
 drivers/net/virtio/virtio_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index fbc96df..e30377c 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -744,8 +744,9 @@ virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, 
uint16_t nb_pkts)
 
virtio_rmb();
 
-   num = (uint16_t)(likely(nb_used <= nb_pkts) ? nb_used : nb_pkts);
-   num = (uint16_t)(likely(num <= VIRTIO_MBUF_BURST_SZ) ? num : 
VIRTIO_MBUF_BURST_SZ);
+   num = likely(nb_used <= nb_pkts) ? nb_used : nb_pkts;
+   if (unlikely(num > VIRTIO_MBUF_BURST_SZ))
+   num = VIRTIO_MBUF_BURST_SZ;
if (likely(num > DESC_PER_CACHELINE))
num = num - ((vq->vq_used_cons_idx + num) % DESC_PER_CACHELINE);
 
-- 
2.7.4



[dpdk-dev] [RFC 0/6] virtio1.1 prototype updates

2017-07-18 Thread Tiwei Bie
This patchset depends on below patchset:

http://dpdk.org/ml/archives/dev/2017-June/068315.html

I'll also collect these public patches into my github repo:

https://github.com/btw616/dpdk-virtio1.1

Best regards,
Tiwei Bie

Tiwei Bie (6):
  net/virtio: optimize the rx path
  vhost: optimize enqueue path
  net/virtio: optimize the tx path
  net/virtio: revert the changes in 18dc1b1ac
  vhost: minor refinement
  virtio1.1: introduce the DESC_WB flag

 drivers/net/virtio/virtio-1.1.h  |   1 +
 drivers/net/virtio/virtio_ethdev.c   |   5 +-
 drivers/net/virtio/virtio_ethdev.h   |   2 +
 drivers/net/virtio/virtio_rxtx.c | 278 +++
 drivers/net/virtio/virtio_rxtx_1.1.c | 112 +++---
 drivers/net/virtio/virtqueue.h   |   2 +
 lib/librte_vhost/virtio-1.1.h|   1 +
 lib/librte_vhost/virtio_net.c| 221 ++--
 8 files changed, 336 insertions(+), 286 deletions(-)

-- 
2.7.4



[dpdk-dev] [RFC 2/6] vhost: optimize enqueue path

2017-07-18 Thread Tiwei Bie
Signed-off-by: Tiwei Bie 
---
 lib/librte_vhost/virtio_net.c | 185 --
 1 file changed, 88 insertions(+), 97 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index c0b4dde..0888d2b 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -583,129 +583,120 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t 
queue_id,
return pkt_idx;
 }
 
-static inline int __attribute__((always_inline))
-enqueue_pkt(struct virtio_net *dev, struct vring_desc_1_1 *descs,
-   uint16_t desc_idx, struct rte_mbuf *m)
-{
-   uint32_t desc_avail, desc_offset;
-   uint32_t mbuf_avail, mbuf_offset;
-   uint32_t cpy_len;
-   struct vring_desc_1_1 *desc;
-   uint64_t desc_addr;
-   struct virtio_net_hdr_mrg_rxbuf *hdr;
-
-   desc = &descs[desc_idx];
-   desc_addr = rte_vhost_gpa_to_vva(dev->mem, desc->addr);
-   /*
-* Checking of 'desc_addr' placed outside of 'unlikely' macro to avoid
-* performance issue with some versions of gcc (4.8.4 and 5.3.0) which
-* otherwise stores offset on the stack instead of in a register.
-*/
-   if (unlikely(desc->len < dev->vhost_hlen) || !desc_addr)
-   return -1;
-
-   rte_prefetch0((void *)(uintptr_t)desc_addr);
-
-   hdr = (struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)desc_addr;
-   virtio_enqueue_offload(m, &hdr->hdr);
-   vhost_log_write(dev, desc->addr, dev->vhost_hlen);
-   PRINT_PACKET(dev, (uintptr_t)desc_addr, dev->vhost_hlen, 0);
-
-   desc_offset = dev->vhost_hlen;
-   desc_avail  = desc->len - dev->vhost_hlen;
-
-   mbuf_avail  = rte_pktmbuf_data_len(m);
-   mbuf_offset = 0;
-   while (mbuf_avail != 0 || m->next != NULL) {
-   /* done with current mbuf, fetch next */
-   if (mbuf_avail == 0) {
-   m = m->next;
-
-   mbuf_offset = 0;
-   mbuf_avail  = rte_pktmbuf_data_len(m);
-   }
-
-   /* done with current desc buf, fetch next */
-   if (desc_avail == 0) {
-   if ((desc->flags & VRING_DESC_F_NEXT) == 0) {
-   /* Room in vring buffer is not enough */
-   return -1;
-   }
-
-   rte_panic("Shouldn't reach here\n");
-   /** NOTE: we should not come here with current
-   virtio-user implementation **/
-   desc_idx = (desc_idx + 1); // & (vq->size - 1);
-   desc = &descs[desc_idx];
-   if (unlikely(!(desc->flags & DESC_HW)))
-   return -1;
-
-   desc_addr = rte_vhost_gpa_to_vva(dev->mem, desc->addr);
-   if (unlikely(!desc_addr))
-   return -1;
-
-   desc_offset = 0;
-   desc_avail  = desc->len;
-   }
-
-   cpy_len = RTE_MIN(desc_avail, mbuf_avail);
-   rte_memcpy((void *)((uintptr_t)(desc_addr + desc_offset)),
-   rte_pktmbuf_mtod_offset(m, void *, mbuf_offset),
-   cpy_len);
-   vhost_log_write(dev, desc->addr + desc_offset, cpy_len);
-   PRINT_PACKET(dev, (uintptr_t)(desc_addr + desc_offset),
-cpy_len, 0);
-
-   mbuf_avail  -= cpy_len;
-   mbuf_offset += cpy_len;
-   desc_avail  -= cpy_len;
-   desc_offset += cpy_len;
-   }
-
-   return 0;
-}
-
 static inline uint32_t __attribute__((always_inline))
 vhost_enqueue_burst_1_1(struct virtio_net *dev, uint16_t queue_id,
  struct rte_mbuf **pkts, uint32_t count)
 {
struct vhost_virtqueue *vq;
+   struct vring_desc_1_1 *descs;
+   uint16_t head_idx, idx;
+   uint16_t mask;
uint16_t i;
-   uint16_t idx;
-   struct vring_desc_1_1 *desc;
-   uint16_t head_idx;
 
vq = dev->virtqueue[queue_id];
if (unlikely(vq->enabled == 0))
return 0;
 
-   head_idx = vq->last_used_idx;
-   desc = vq->desc_1_1;
-   count = RTE_MIN(count, (uint32_t)MAX_PKT_BURST);
+   descs = vq->desc_1_1;
+   mask = vq->size - 1;
+   head_idx = vq->last_used_idx & mask;
 
for (i = 0; i < count; i++) {
+   uint32_t desc_avail, desc_offset;
+   uint32_t mbuf_avail, mbuf_offset;
+   uint32_t cpy_len;
+   struct vring_desc_1_1 *desc;
+   uint64_t desc_addr;
+   struct virtio_net_hdr_mrg_rxbuf *hdr;
+   struct rte_mbuf *m = pkts[i];
+
/

[dpdk-dev] [RFC 1/6] net/virtio: optimize the rx path

2017-07-18 Thread Tiwei Bie
Signed-off-by: Tiwei Bie 
---
 drivers/net/virtio/virtio_ethdev.c |   5 +-
 drivers/net/virtio/virtio_ethdev.h |   2 +
 drivers/net/virtio/virtio_rxtx.c   | 255 -
 3 files changed, 142 insertions(+), 120 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c 
b/drivers/net/virtio/virtio_ethdev.c
index 334c4b8..566eede 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1241,7 +1241,10 @@ static void
 rx_func_get(struct rte_eth_dev *eth_dev)
 {
struct virtio_hw *hw = eth_dev->data->dev_private;
-   if (0 && vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF))
+
+   if (vtpci_version_1_1(hw))
+   eth_dev->rx_pkt_burst = &virtio_recv_pkts_1_1;
+   else if (vtpci_with_feature(hw, VIRTIO_NET_F_MRG_RXBUF))
eth_dev->rx_pkt_burst = &virtio_recv_mergeable_pkts;
else
eth_dev->rx_pkt_burst = &virtio_recv_pkts;
diff --git a/drivers/net/virtio/virtio_ethdev.h 
b/drivers/net/virtio/virtio_ethdev.h
index deed34e..8bd699d 100644
--- a/drivers/net/virtio/virtio_ethdev.h
+++ b/drivers/net/virtio/virtio_ethdev.h
@@ -99,6 +99,8 @@ int  virtio_dev_tx_queue_setup(struct rte_eth_dev *dev, 
uint16_t tx_queue_id,
 
 uint16_t virtio_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
+uint16_t virtio_recv_pkts_1_1(void *rx_queue, struct rte_mbuf **rx_pkts,
+   uint16_t nb_pkts);
 
 uint16_t virtio_recv_mergeable_pkts(void *rx_queue, struct rte_mbuf **rx_pkts,
uint16_t nb_pkts);
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 3dc5eaf..3983626 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -116,7 +116,7 @@ vq_ring_free_chain(struct virtqueue *vq, uint16_t desc_idx)
 }
 
 static inline uint16_t
-virtqueue_dequeue_burst_rx_1_0(struct virtqueue *vq, struct rte_mbuf **rx_pkts,
+virtqueue_dequeue_burst_rx(struct virtqueue *vq, struct rte_mbuf **rx_pkts,
   uint32_t *len, uint16_t num)
 {
struct vring_used_elem *uep;
@@ -151,53 +151,6 @@ virtqueue_dequeue_burst_rx_1_0(struct virtqueue *vq, 
struct rte_mbuf **rx_pkts,
return i;
 }
 
-static inline uint16_t
-virtqueue_dequeue_burst_rx_1_1(struct virtqueue *vq, struct rte_mbuf **rx_pkts,
-  uint32_t *len, uint16_t num)
-{
-   struct vring_desc_1_1 *desc = vq->vq_ring.desc_1_1;
-   struct rte_mbuf *cookie;
-   uint16_t used_idx;
-   uint16_t i;
-
-   for (i = 0; i < num ; i++) {
-   used_idx = (uint16_t)(vq->vq_used_cons_idx & (vq->vq_nentries - 
1));
-   if ((desc[used_idx].flags & DESC_HW))
-   break;
-
-   len[i] = desc[used_idx].len;
-   cookie = vq->vq_descx[used_idx].cookie;
-
-   if (unlikely(cookie == NULL)) {
-   PMD_DRV_LOG(ERR, "vring descriptor with no mbuf cookie 
at %u\n",
-   vq->vq_used_cons_idx);
-   break;
-   }
-   vq->vq_descx[used_idx].cookie = NULL;
-
-   rte_prefetch0(cookie);
-#if 0
-   rte_packet_prefetch(rte_pktmbuf_mtod(cookie, void *));
-#endif
-   rx_pkts[i]  = cookie;
-
-   vq->vq_used_cons_idx++;
-   vq->vq_free_cnt++;
-   }
-
-   return i;
-}
-
-static inline uint16_t
-virtqueue_dequeue_burst_rx(struct virtqueue *vq, struct rte_mbuf **rx_pkts,
-  uint32_t *len, uint16_t num)
-{
-   if (vtpci_version_1_1(vq->hw))
-   return virtqueue_dequeue_burst_rx_1_1(vq, rx_pkts, len, num);
-   else
-   return virtqueue_dequeue_burst_rx_1_0(vq, rx_pkts, len, num);
-}
-
 #ifndef DEFAULT_TX_FREE_THRESH
 #define DEFAULT_TX_FREE_THRESH 32
 #endif
@@ -226,9 +179,8 @@ virtio_xmit_cleanup(struct virtqueue *vq, uint16_t num)
}
 }
 
-
 static inline int
-virtqueue_enqueue_recv_refill_1_0(struct virtqueue *vq, struct rte_mbuf 
*cookie)
+virtqueue_enqueue_recv_refill(struct virtqueue *vq, struct rte_mbuf *cookie)
 {
struct vq_desc_extra *dxp;
struct virtio_hw *hw = vq->hw;
@@ -267,50 +219,6 @@ virtqueue_enqueue_recv_refill_1_0(struct virtqueue *vq, 
struct rte_mbuf *cookie)
return 0;
 }
 
-static inline int
-virtqueue_enqueue_recv_refill_1_1(struct virtqueue *vq, struct rte_mbuf 
*cookie)
-{
-   struct vq_desc_extra *dxp;
-   struct virtio_hw *hw = vq->hw;
-   uint16_t needed = 1;
-   uint16_t idx;
-   struct vring_desc_1_1 *desc = vq->vq_ring.desc_1_1;
-
-   if (unlikely(vq->vq_free_cnt == 0))
-   return -ENOSPC;
-   if (unlikely(vq->vq_free_cnt < needed))
-   return -EMSGSIZE;
-
-   idx = vq->vq_desc_head_idx & (vq->vq_nent

[dpdk-dev] [RFC 4/6] net/virtio: revert the changes in 18dc1b1ac

2017-07-18 Thread Tiwei Bie
Revert the changes in 18dc1b1ac, because we want to test the
performance similar to the real world case.

Signed-off-by: Tiwei Bie 
---
 drivers/net/virtio/virtio_rxtx.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 3983626..7be9aae 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -139,9 +139,7 @@ virtqueue_dequeue_burst_rx(struct virtqueue *vq, struct 
rte_mbuf **rx_pkts,
}
 
rte_prefetch0(cookie);
-#if 0
rte_packet_prefetch(rte_pktmbuf_mtod(cookie, void *));
-#endif
rx_pkts[i]  = cookie;
vq->vq_used_cons_idx++;
vq_ring_free_chain(vq, desc_idx);
@@ -512,9 +510,7 @@ static void
 virtio_update_packet_stats(struct virtnet_stats *stats, struct rte_mbuf *mbuf)
 {
uint32_t s = mbuf->pkt_len;
-#if 0
struct ether_addr *ea;
-#endif
 
if (s == 64) {
stats->size_bins[1]++;
@@ -533,7 +529,6 @@ virtio_update_packet_stats(struct virtnet_stats *stats, 
struct rte_mbuf *mbuf)
stats->size_bins[7]++;
}
 
-#if 0
ea = rte_pktmbuf_mtod(mbuf, struct ether_addr *);
if (is_multicast_ether_addr(ea)) {
if (is_broadcast_ether_addr(ea))
@@ -541,7 +536,6 @@ virtio_update_packet_stats(struct virtnet_stats *stats, 
struct rte_mbuf *mbuf)
else
stats->multicast++;
}
-#endif
 }
 
 /* Optionally fill offload information in structure */
@@ -664,6 +658,9 @@ virtio_recv_pkts_1_1(void *rx_queue, struct rte_mbuf 
**rx_pkts, uint16_t nb_pkts
 
dxp = &vq->vq_descx[used_idx & (vq->vq_nentries - 1)];
 
+   rte_packet_prefetch(rte_pktmbuf_mtod(
+   (struct rte_mbuf *)dxp->cookie, void *));
+
len = desc->len;
rxm = dxp->cookie;
dxp->cookie = nmb;
-- 
2.7.4



[dpdk-dev] [RFC 3/6] net/virtio: optimize the tx path

2017-07-18 Thread Tiwei Bie
Signed-off-by: Tiwei Bie 
---
 drivers/net/virtio/virtio_rxtx_1.1.c | 65 
 1 file changed, 28 insertions(+), 37 deletions(-)

diff --git a/drivers/net/virtio/virtio_rxtx_1.1.c 
b/drivers/net/virtio/virtio_rxtx_1.1.c
index 4602e6d..883a027 100644
--- a/drivers/net/virtio/virtio_rxtx_1.1.c
+++ b/drivers/net/virtio/virtio_rxtx_1.1.c
@@ -80,42 +80,6 @@ virtio_xmit_cleanup(struct virtqueue *vq)
}
 }
 
-static inline void
-virtio_xmit(struct virtnet_tx *txvq, struct rte_mbuf *mbuf, int first_mbuf)
-{
-   struct virtio_tx_region *txr = txvq->virtio_net_hdr_mz->addr;
-   struct virtqueue *vq = txvq->vq;
-   struct vring_desc_1_1 *desc = vq->vq_ring.desc_1_1;
-   uint16_t idx;
-   uint16_t head_idx = (vq->vq_avail_idx++) & (vq->vq_nentries - 1);
-   struct vq_desc_extra *dxp;
-
-   idx = head_idx;
-   vq->vq_free_cnt -= mbuf->nb_segs + 1;
-
-   dxp = &vq->vq_descx[idx];
-   if (dxp->cookie != NULL)
-   rte_pktmbuf_free(dxp->cookie);
-   dxp->cookie = mbuf;
-
-   desc[idx].addr  = txvq->virtio_net_hdr_mem +
- RTE_PTR_DIFF(&txr[idx].tx_hdr, txr);
-   desc[idx].len   = vq->hw->vtnet_hdr_size;
-   desc[idx].flags = VRING_DESC_F_NEXT;
-   if (!first_mbuf)
-   desc[idx].flags |= DESC_HW;
-
-   do {
-   idx = (vq->vq_avail_idx++) & (vq->vq_nentries - 1);
-   desc[idx].addr  = VIRTIO_MBUF_DATA_DMA_ADDR(mbuf, vq);
-   desc[idx].len   = mbuf->data_len;
-   desc[idx].flags = DESC_HW | VRING_DESC_F_NEXT;
-   } while ((mbuf = mbuf->next) != NULL);
-
-   desc[idx].flags &= ~VRING_DESC_F_NEXT;
-
-}
-
 uint16_t
 virtio_xmit_pkts_1_1(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t 
nb_pkts)
 {
@@ -123,6 +87,9 @@ virtio_xmit_pkts_1_1(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts
struct virtqueue *vq = txvq->vq;
uint16_t i;
uint16_t head_idx = vq->vq_avail_idx;
+   struct vring_desc_1_1 *desc = vq->vq_ring.desc_1_1;
+   uint16_t idx;
+   struct vq_desc_extra *dxp;
 
if (unlikely(nb_pkts < 1))
return nb_pkts;
@@ -134,6 +101,7 @@ virtio_xmit_pkts_1_1(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts
 
for (i = 0; i < nb_pkts; i++) {
struct rte_mbuf *txm = tx_pkts[i];
+   struct virtio_tx_region *txr = txvq->virtio_net_hdr_mz->addr;
 
if (unlikely(txm->nb_segs + 1 > vq->vq_free_cnt)) {
virtio_xmit_cleanup(vq);
@@ -145,8 +113,31 @@ virtio_xmit_pkts_1_1(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts
}
}
 
-   virtio_xmit(txvq, txm, i == 0);
txvq->stats.bytes += txm->pkt_len;
+
+   vq->vq_free_cnt -= txm->nb_segs + 1;
+
+   idx = (vq->vq_avail_idx++) & (vq->vq_nentries - 1);
+   dxp = &vq->vq_descx[idx];
+   if (dxp->cookie != NULL)
+   rte_pktmbuf_free(dxp->cookie);
+   dxp->cookie = txm;
+
+   desc[idx].addr  = txvq->virtio_net_hdr_mem +
+ RTE_PTR_DIFF(&txr[idx].tx_hdr, txr);
+   desc[idx].len   = vq->hw->vtnet_hdr_size;
+   desc[idx].flags = VRING_DESC_F_NEXT;
+   if (i != 0)
+   desc[idx].flags |= DESC_HW;
+
+   do {
+   idx = (vq->vq_avail_idx++) & (vq->vq_nentries - 1);
+   desc[idx].addr  = VIRTIO_MBUF_DATA_DMA_ADDR(txm, vq);
+   desc[idx].len   = txm->data_len;
+   desc[idx].flags = DESC_HW | VRING_DESC_F_NEXT;
+   } while ((txm = txm->next) != NULL);
+
+   desc[idx].flags &= ~VRING_DESC_F_NEXT;
}
 
if (likely(i)) {
-- 
2.7.4



[dpdk-dev] [RFC 5/6] vhost: minor refinement

2017-07-18 Thread Tiwei Bie
Manually prefetch the first desc in dequeue path.

Signed-off-by: Tiwei Bie 
---
 lib/librte_vhost/virtio_net.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 0888d2b..08d53d9 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1259,6 +1259,7 @@ vhost_dequeue_burst_1_1(struct virtio_net *dev, struct 
vhost_virtqueue *vq,
 
vq->last_used_idx = desc_idx;
if (likely(i)) {
+   rte_prefetch0(&desc[head_idx & (vq->size - 1)]);
for (desc_idx = head_idx + 1;
 desc_idx != vq->last_used_idx;
 desc_idx++) {
-- 
2.7.4



[dpdk-dev] [RFC 6/6] virtio1.1: introduce the DESC_WB flag

2017-07-18 Thread Tiwei Bie
This patch introduces the DESC_WB flag, and adopts it in the virtio
Tx path. This flag can help to reduce the memory write operations on
the descriptor ring from the backend. So it could help to reduce the
PCIe transactions in a hardware backend case.

Normally the DESC_WB like mechanism is used in a head/tail design.
But in this prototype, head/tail isn't used. So backend still needs
to judge whether a desc is available by checking the DESC_HW flag.
Then some tricks are needed by the frontend when setting the DESC_WB
flags. Otherwise backend may see some descriptors' DESC_HW are set,
but actually they are not available to the backend.

Signed-off-by: Tiwei Bie 
---
 drivers/net/virtio/virtio-1.1.h  |  1 +
 drivers/net/virtio/virtio_rxtx.c | 14 +
 drivers/net/virtio/virtio_rxtx_1.1.c | 55 +---
 drivers/net/virtio/virtqueue.h   |  2 ++
 lib/librte_vhost/virtio-1.1.h|  1 +
 lib/librte_vhost/virtio_net.c| 37 +++-
 6 files changed, 79 insertions(+), 31 deletions(-)

diff --git a/drivers/net/virtio/virtio-1.1.h b/drivers/net/virtio/virtio-1.1.h
index 48cbb18..bd76761 100644
--- a/drivers/net/virtio/virtio-1.1.h
+++ b/drivers/net/virtio/virtio-1.1.h
@@ -8,6 +8,7 @@
 #define BATCH_NOT_FIRST 0x0010
 #define BATCH_NOT_LAST  0x0020
 #define DESC_HW0x0080
+#define DESC_WB0x0100
 
 struct vring_desc_1_1 {
 uint64_t addr;
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 7be9aae..0248638 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -153,6 +153,10 @@ virtqueue_dequeue_burst_rx(struct virtqueue *vq, struct 
rte_mbuf **rx_pkts,
 #define DEFAULT_TX_FREE_THRESH 32
 #endif
 
+#ifndef DEFAULT_TX_RS_THRESH
+#define DEFAULT_TX_RS_THRESH 32
+#endif
+
 /* Cleanup from completed transmits. */
 static void
 virtio_xmit_cleanup(struct virtqueue *vq, uint16_t num)
@@ -434,6 +438,7 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
struct virtqueue *vq = hw->vqs[vtpci_queue_idx];
struct virtnet_tx *txvq;
uint16_t tx_free_thresh;
+   uint16_t tx_rs_thresh;
uint16_t desc_idx;
 
PMD_INIT_FUNC_TRACE();
@@ -451,6 +456,9 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
if (tx_free_thresh == 0)
tx_free_thresh =
RTE_MIN(vq->vq_nentries / 4, DEFAULT_TX_FREE_THRESH);
+   tx_rs_thresh = tx_conf->tx_rs_thresh;
+   if (tx_rs_thresh == 0)
+   tx_rs_thresh = DEFAULT_TX_RS_THRESH;
 
if (tx_free_thresh >= (vq->vq_nentries - 3)) {
RTE_LOG(ERR, PMD, "tx_free_thresh must be less than the "
@@ -461,7 +469,13 @@ virtio_dev_tx_queue_setup(struct rte_eth_dev *dev,
return -EINVAL;
}
 
+   if (!rte_is_power_of_2(tx_free_thresh)) {
+   RTE_LOG(ERR, PMD, "tx_free_thresh is not powerof 2");
+   return -EINVAL;
+   }
+
vq->vq_free_thresh = tx_free_thresh;
+   vq->vq_rs_thresh = tx_rs_thresh;
 
if (hw->use_simple_rxtx) {
uint16_t mid_idx  = vq->vq_nentries >> 1;
diff --git a/drivers/net/virtio/virtio_rxtx_1.1.c 
b/drivers/net/virtio/virtio_rxtx_1.1.c
index 883a027..38f6a4a 100644
--- a/drivers/net/virtio/virtio_rxtx_1.1.c
+++ b/drivers/net/virtio/virtio_rxtx_1.1.c
@@ -63,21 +63,28 @@
 #include "virtio_rxtx.h"
 
 /* Cleanup from completed transmits. */
-static void
+static inline int
 virtio_xmit_cleanup(struct virtqueue *vq)
 {
-   uint16_t idx;
-   uint16_t size = vq->vq_nentries;
+   uint16_t clean_to, idx;
+   uint16_t mask = vq->vq_nentries - 1;
struct vring_desc_1_1 *desc = vq->vq_ring.desc_1_1;
+   uint16_t last_cleaned = vq->vq_used_cons_idx - 1;
 
-   idx = vq->vq_used_cons_idx & (size - 1);
-   while ((desc[idx].flags & DESC_HW) == 0) {
-   idx = (++vq->vq_used_cons_idx) & (size - 1);
-   vq->vq_free_cnt++;
-
-   if (vq->vq_free_cnt >= size)
-   break;
+   clean_to = last_cleaned + vq->vq_rs_thresh;
+   if ((desc[clean_to & mask].flags & DESC_HW) != 0) {
+   PMD_TX_LOG(DEBUG, "TX descriptor %d is not done",
+   clean_to & mask);
+   return -1;
}
+
+   for (idx = last_cleaned + 2; idx < clean_to; idx++)
+   desc[idx & mask].flags &= ~DESC_HW;
+
+   vq->vq_used_cons_idx = clean_to + 1;
+   vq->vq_free_cnt += vq->vq_rs_thresh;
+
+   return 0;
 }
 
 uint16_t
@@ -90,6 +97,7 @@ virtio_xmit_pkts_1_1(void *tx_queue, struct rte_mbuf 
**tx_pkts, uint16_t nb_pkts
struct vring_desc_1_1 *desc = vq->vq_ring.desc_1_1;
uint16_t idx;
struct vq_desc_extra *dxp;
+   ui

[dpdk-dev] [PATCH] all: refactor coding style

2017-07-19 Thread Tiwei Bie
Remove the unwanted spaces before `;' across DPDK source code
by below one-liner with some minor manual refinements.

find . -name '*.[ch]' | xargs sed -i 's/\([^;(]\) \+;/\1;/g'

The fixes for cmdline library are skipped, because it has a
different coding style. It deserves a separate cleanup if
necessary. The fixes for drivers' base code are also skipped
to keep the base code intact.

Signed-off-by: Tiwei Bie 
---
 app/test-pmd/testpmd.h |  4 ++--
 drivers/crypto/qat/qat_adf/icp_qat_fw.h|  2 +-
 drivers/event/dpaa2/dpaa2_eventdev.c   |  2 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c   |  2 +-
 drivers/net/bnx2x/bnx2x.c  |  3 ++-
 drivers/net/bnx2x/elink.h  |  2 +-
 drivers/net/e1000/igb_pf.c |  2 +-
 drivers/net/ena/ena_ethdev.c   |  4 ++--
 drivers/net/qede/qede_ethdev.c |  2 +-
 drivers/net/vhost/rte_eth_vhost.c  |  2 +-
 drivers/net/virtio/virtio_rxtx.c   |  4 ++--
 drivers/net/xenvirt/rte_eth_xenvirt.c  |  4 ++--
 drivers/net/xenvirt/rte_xen_lib.c  |  2 +-
 drivers/net/xenvirt/virtqueue.h|  2 +-
 examples/ip_pipeline/cpu_core_map.c|  4 ++--
 examples/multi_process/l2fwd_fork/main.c   |  2 +-
 examples/netmap_compat/lib/compat_netmap.c |  2 +-
 examples/performance-thread/l3fwd-thread/main.c|  2 +-
 examples/qos_sched/app_thread.c|  2 +-
 examples/quota_watermark/qw/main.c |  2 +-
 examples/vhost_xen/xenstore_parse.c|  3 +--
 lib/librte_distributor/rte_distributor.c   | 12 +-
 lib/librte_eal/linuxapp/eal/eal_memory.c   |  2 +-
 lib/librte_eal/linuxapp/eal/eal_xen_memory.c   |  2 +-
 lib/librte_eal/linuxapp/kni/ethtool/igb/igb_main.c |  4 ++--
 .../linuxapp/kni/ethtool/ixgbe/ixgbe_main.c|  2 +-
 .../linuxapp/kni/ethtool/ixgbe/kcompat.c   |  2 +-
 lib/librte_ether/rte_ethdev.c  |  2 +-
 lib/librte_sched/rte_approx.c  |  8 +++
 lib/librte_sched/rte_bitmap.h  |  3 ++-
 test/test/test_cryptodev.c |  2 +-
 test/test/test_cryptodev_perf.c| 26 +++---
 test/test/test_eventdev_sw.c   |  2 +-
 test/test/test_malloc.c|  4 ++--
 test/test/test_memory.c|  2 +-
 test/test/test_mempool.c   |  2 +-
 test/test/test_ring.c  |  6 ++---
 test/test/test_table_acl.c |  2 +-
 test/test/test_table_pipeline.c|  2 +-
 39 files changed, 69 insertions(+), 70 deletions(-)

diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index c9d7739..8f88d70 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -118,8 +118,8 @@ struct fwd_stream {
unsigned int rx_packets;  /**< received packets */
unsigned int tx_packets;  /**< received packets transmitted */
unsigned int fwd_dropped; /**< received packets not forwarded */
-   unsigned int rx_bad_ip_csum ; /**< received packets has bad ip checksum 
*/
-   unsigned int rx_bad_l4_csum ; /**< received packets has bad l4 checksum 
*/
+   unsigned int rx_bad_ip_csum; /**< received packets has bad ip checksum 
*/
+   unsigned int rx_bad_l4_csum; /**< received packets has bad l4 checksum 
*/
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
uint64_t core_cycles; /**< used for RX and TX processing */
 #endif
diff --git a/drivers/crypto/qat/qat_adf/icp_qat_fw.h 
b/drivers/crypto/qat/qat_adf/icp_qat_fw.h
index 5de34d5..c80989b 100644
--- a/drivers/crypto/qat/qat_adf/icp_qat_fw.h
+++ b/drivers/crypto/qat/qat_adf/icp_qat_fw.h
@@ -51,7 +51,7 @@
 
 #define QAT_FIELD_SET(flags, val, bitpos, mask) \
 { (flags) = (((flags) & (~((mask) << (bitpos | \
-   (((val) & (mask)) << (bitpos))) ; }
+   (((val) & (mask)) << (bitpos))); }
 
 #define QAT_FIELD_GET(flags, bitpos, mask) \
(((flags) >> (bitpos)) & (mask))
diff --git a/drivers/event/dpaa2/dpaa2_eventdev.c 
b/drivers/event/dpaa2/dpaa2_eventdev.c
index ed57376..89bc1ce 100644
--- a/drivers/event/dpaa2/dpaa2_eventdev.c
+++ b/drivers/event/dpaa2/dpaa2_eventdev.c
@@ -587,7 +587,7 @@ dpaa2_eventdev_setup_dpci(struct dpaa2_dpci_dev *dpci_dev,
dpci_dev->queue[DPAA2_EVENT_DPCI_ATOMIC_QUEUE].cb =
dpaa2_eventdev_process_atomic;
 
-   for (i = 0 ; i < DPAA2_EVENT_DPCI_MAX_QUEUES; i++) {
+   for (i = 0; i < DPAA2_EVENT_DPCI_MAX_QUEUES; i++) {
rx_queue_cfg.user_ctx = (uint64_t)(&dpci_dev->queue[i]);
ret = dpci_set_rx_

Re: [dpdk-dev] [PATCH] all: refactor coding style

2017-07-19 Thread Tiwei Bie
On Wed, Jul 19, 2017 at 05:24:38PM +0800, Van Haaren, Harry wrote:
> > From: dev [mailto:dev-boun...@dpdk.org] On Behalf Of Tiwei Bie
> > Sent: Wednesday, July 19, 2017 10:07 AM
> > To: dev@dpdk.org
> > Cc: tho...@monjalon.net
> > Subject: [dpdk-dev] [PATCH] all: refactor coding style
> > 
> > Remove the unwanted spaces before `;' across DPDK source code
> > by below one-liner with some minor manual refinements.
> > 
> > find . -name '*.[ch]' | xargs sed -i 's/\([^;(]\) \+;/\1;/g'
> > 
> > The fixes for cmdline library are skipped, because it has a
> > different coding style. It deserves a separate cleanup if
> > necessary. The fixes for drivers' base code are also skipped
> > to keep the base code intact.
> > 
> > Signed-off-by: Tiwei Bie 
> 
> Hi Tiwei,
> 
> Although the idea and motivation for code-cleanup are good, performing
> large cleanup across a code-base is not a good solution. The reason that
> these types of cleanups (or even re-formatting the entire codebase) are not
> performed often is that it "invalidates" any currently-in-progress patch-sets.
> As a result, more work is required from many contributors to rebase useful
> features due to across-the-board white-space cleanups.
> 
> Just expressing concern that we need to think carefully about the impacts
> of such a patch.
> 

Yeah, I agree. Such patch may cause many conflicts. But this patch
is almost generated automatically, that is to say, it's a quick work.
And it's more like some fixes (for the bad coding style) rather than
silly re-formatting done by `indent'. So I just want to share it with
the community, and see the potential feedbacks. Thank you for your
comments! :)

Best regards,
Tiwei Bie


Re: [dpdk-dev] [PATCH] all: refactor coding style

2017-07-19 Thread Tiwei Bie
On Thu, Jul 20, 2017 at 10:34:39AM +0530, Shreyansh Jain wrote:
> On Wednesday 19 July 2017 02:36 PM, Tiwei Bie wrote:
> > Remove the unwanted spaces before `;' across DPDK source code
> > by below one-liner with some minor manual refinements.
> > 
> > find . -name '*.[ch]' | xargs sed -i 's/\([^;(]\) \+;/\1;/g'
> > 
> > The fixes for cmdline library are skipped, because it has a
> > different coding style. It deserves a separate cleanup if
> > necessary. The fixes for drivers' base code are also skipped
> > to keep the base code intact.
> > 
> > Signed-off-by: Tiwei Bie 
> > ---
[...]
> > /* compute the number of steps to the right */
> > diff --git a/lib/librte_sched/rte_bitmap.h b/lib/librte_sched/rte_bitmap.h
> > index 010d752..e487b58 100644
> > --- a/lib/librte_sched/rte_bitmap.h
> > +++ b/lib/librte_sched/rte_bitmap.h
> > @@ -500,7 +500,8 @@ __rte_bitmap_scan_read(struct rte_bitmap *bmp, uint32_t 
> > *pos, uint64_t *slab)
> > uint64_t *slab2;
> > slab2 = bmp->array2 + bmp->index2;
> > -   for ( ; bmp->go2 ; bmp->index2 ++, slab2 ++, bmp->go2 = bmp->index2 & 
> > RTE_BITMAP_CL_SLAB_MASK) {
> > +   for ( ; bmp->go2; bmp->index2++, slab2++,
> > + bmp->go2 = bmp->index2 & RTE_BITMAP_CL_SLAB_MASK) {
> 
>
> Trivial: space before ';' in 'for' here should also be removed.
> 

Thank you for your feedbacks! :-)

Hmm.. Actually the space between `(' and `;' was kept intentionally
when I wrote this 's/\([^;(]\) \+;/\1;/g' sed script. There are many
other such cases. It's acceptable to me, and I thought we like it:

diff --git i/app/test-eventdev/parser.h w/app/test-eventdev/parser.h
index 75a5a3b..372b85f 100644
--- i/app/test-eventdev/parser.h
+++ w/app/test-eventdev/parser.h
@@ -41,7 +41,7 @@
 #define skip_white_spaces(pos) \
 ({ \
__typeof__(pos) _p = (pos); \
-   for ( ; isspace(*_p); _p++) \
+   for (; isspace(*_p); _p++)  \
;   \
_p; \
 })
diff --git i/app/test-eventdev/test_perf_common.c 
w/app/test-eventdev/test_perf_common.c
index a5b768c..36b78bf 100644
--- i/app/test-eventdev/test_perf_common.c
+++ w/app/test-eventdev/test_perf_common.c
@@ -284,7 +284,7 @@ perf_event_dev_port_setup(struct evt_test *test, struct 
evt_options *opt,
.new_event_threshold = 1200,
};
prod = 0;
-   for ( ; port < perf_nb_event_ports(opt); port++) {
+   for (; port < perf_nb_event_ports(opt); port++) {
struct prod_data *p = &t->prod[port];
 
p->dev_id = opt->dev_id;
diff --git i/drivers/net/bonding/rte_eth_bond_pmd.c 
w/drivers/net/bonding/rte_eth_bond_pmd.c
index 383e27c..5d8e068 100644
--- i/drivers/net/bonding/rte_eth_bond_pmd.c
+++ w/drivers/net/bonding/rte_eth_bond_pmd.c
@@ -371,7 +371,7 @@ bond_ethdev_tx_burst_8023ad_fast_queue(void *queue, struct 
rte_mbuf **bufs,
/* If tx burst fails move packets to end of bufs */
if (unlikely(num_tx_slave < slave_nb_pkts[i])) {
uint16_t j = nb_pkts - num_tx_fail_total;
-   for ( ; num_tx_slave < slave_nb_pkts[i]; j++,
+   for (; num_tx_slave < slave_nb_pkts[i]; j++,
num_tx_slave++)
bufs[j] = slave_bufs[i][num_tx_slave];
}
@@ -1308,7 +1308,7 @@ bond_ethdev_tx_burst_8023ad(void *queue, struct rte_mbuf 
**bufs,
slave_bufs[i], slave_nb_pkts[i]);
 
/* If tx burst fails drop slow packets */
-   for ( ; num_tx_slave < slave_slow_nb_pkts[i]; num_tx_slave++)
+   for (; num_tx_slave < slave_slow_nb_pkts[i]; num_tx_slave++)
rte_pktmbuf_free(slave_bufs[i][num_tx_slave]);
 
num_tx_total += num_tx_slave - slave_slow_nb_pkts[i];
@@ -1317,7 +1317,7 @@ bond_ethdev_tx_burst_8023ad(void *queue, struct rte_mbuf 
**bufs,
/* If tx burst fails move packets to end of bufs */
if (unlikely(num_tx_slave < slave_nb_pkts[i])) {
uint16_t j = nb_pkts - num_tx_fail_total;
-   for ( ; num_tx_slave < slave_nb_pkts[i]; j++, 
num_tx_slave++)
+   for (; num_tx_slave < slave_nb_pkts[i]; j++, 
num_tx_slave++)
bufs[j] = slave_bufs[i][num_tx_slave];
}
}
diff --git i/drivers/net/cxgbe/base/t4_hw.c w/drivers/net/cxgbe/base/t4_hw.c

Re: [dpdk-dev] [PATCH] all: refactor coding style

2017-07-20 Thread Tiwei Bie
On Thu, Jul 20, 2017 at 11:32:18AM +0300, Thomas Monjalon wrote:
> 20/07/2017 10:56, Jens Freimann:
> > On Wed, Jul 19, 2017 at 06:23:21PM +0800, Tiwei Bie wrote:
> > >On Wed, Jul 19, 2017 at 05:24:38PM +0800, Van Haaren, Harry wrote:
> > [...]
> > > > Hi Tiwei,
> > > >
> > > > Although the idea and motivation for code-cleanup are good, performing
> > > > large cleanup across a code-base is not a good solution. The reason that
> > > > these types of cleanups (or even re-formatting the entire codebase) are 
> > > > not
> > > > performed often is that it "invalidates" any currently-in-progress 
> > > > patch-sets.
> > > > As a result, more work is required from many contributors to rebase 
> > > > useful
> > > > features due to across-the-board white-space cleanups.
> > > >
> > > > Just expressing concern that we need to think carefully about the 
> > > > impacts
> > > > of such a patch.
> > > >
> > >
> > > Yeah, I agree. Such patch may cause many conflicts. But this patch
> > > is almost generated automatically, that is to say, it's a quick work.
> > > And it's more like some fixes (for the bad coding style) rather than
> > > silly re-formatting done by `indent'. So I just want to share it with
> > > the community, and see the potential feedbacks. Thank you for your
> > > comments! :)
> > 
> > what I'm more concerned about with these kind of huge clean-ups is
> > that it makes git-blame less useful for me. Next time I want to look
> > up who changed this line I'll just find your cleanup patch. Then I have
> > to do another step to find out which commit introduced the change I'm
> > looking for. 
> > 
> > I'm more for cleaning up these things next time you do a semantic
> > change in this code.
> 
> +1 for doing clean-up when refactoring code

Hi Jens and Thomas,

I agree with your concerns.

But if you look into this patch, you will find that it's not a
huge cleanup. Actually in this patch, although the file list is
long, there are only 69 lines are changed (across the whole DPDK
source code), and only 1 new line is added. The changes in each
file are very minimal. I don't think it will destroy the useful
info you need in git-blame.

I definitely agree that it would be perfect to clean-up the code
when you need to do a semantic change in this code. But you will
also find that it's very possible that you won't need to do a
semantic change to these code for a very long time. And much of
the changed code in this patch is old code. I think the new code
for DPDK has much better quality than before. It's really annoying
(at least to me) each time come across those bad code. :-(

Thank you for sharing your thoughts! :-)

Best regards,
Tiwei Bie 


[dpdk-dev] [PATCH] vhost: make the page logging atomic

2017-08-01 Thread Tiwei Bie
Each dirty page logging operation should be atomic. But it's not
atomic in current implementation. So it's possible that some dirty
pages can't be logged successfully when different threads try to
log different pages into the same byte of the log buffer concurrently.
This patch fixes this issue.

Fixes: b171fad1ffa5 ("vhost: log used vring changes")
Cc: sta...@dpdk.org

Reported-by: Xiao Wang 
Signed-off-by: Tiwei Bie 
---
 lib/librte_vhost/vhost.h | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h
index 0f294f3..6fe72ae 100644
--- a/lib/librte_vhost/vhost.h
+++ b/lib/librte_vhost/vhost.h
@@ -201,10 +201,19 @@ struct virtio_net {
 
 #define VHOST_LOG_PAGE 4096
 
+/*
+ * Atomically set a bit in memory.
+ */
+static __rte_always_inline void
+vhost_set_bit(unsigned int nr, volatile uint8_t *addr)
+{
+   __sync_fetch_and_or_8(addr, (1U << nr));
+}
+
 static __rte_always_inline void
 vhost_log_page(uint8_t *log_base, uint64_t page)
 {
-   log_base[page / 8] |= 1 << (page % 8);
+   vhost_set_bit(page % 8, &log_base[page / 8]);
 }
 
 static __rte_always_inline void
-- 
2.7.4



  1   2   3   4   5   6   7   8   9   >