Skip to contentSkip to conversation

RFC: Support MACSEC offload in the RTE_SECURITY infrastructure.

RFC In review Pavel Belous 3 participants 11 messages Oct 25, 2019 – Jan 27, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover RFC: Support MACSEC offload in the RTE_SECURITY infrastructure.

From: Pavel Belous <[email protected]>

This RFC suggest possible API to implement generic MACSEC HW offload in DPDK infrastructure.

Right now two PMDs implementing MACSEC hw offload via private
API: ixgbe (Intel) and atlantic (Aquantia).

During that private API discussion it was decided to go further with well defined public API, based most probably on rte_security infrastructure.

Here is that previous discussion:

http://inbox.dpdk.org/dev/20190416101145.nVecHKp3w14Ptd_hne-DqHhKyzbre88PwNI-OAowXJM@z/

Declaring macsec API via rte_security gives a good data-centric view on parameters and operations macsec supports. Old, pure functional API (basically ixbe only API) presented function calls with big argument lists which is hard to extend and analyse.

However, I'd like to note rte_security has to be used via explicitly created mempools - this hardens abit the usage.
It also may be hard to extend the structures in the ABI compatible way.

One of the problems with MACSEC is that internally implementation and hardware support could be either very simple, doing only endpoint encryption with a single TX SC (Secure Connection), or quite complex, capable to do flexible filtering and SC matching based on mac, vlan, ethertype and other.

Different macsec hardware supports some custom features and from our experience users would like to configure these as well. Therefore there will probably be needed a number of PMD specific macsec operators support.

Examples include: custom in-the-clear tag (matched by vlan id or mask), configurable internal logic to allow both secure and unsecure traffic, bypass filters on specific ethertypes.
To support such extensions, suggest use rte_security_macsec_op enum with vendor specific operation codes.

In context of rte_security, MACSEC operations should normally be based on security session create and update calls.

Session create is used to setup overall session. Thats equivalent of old macsec enable operation.

Session update is used to update security connections and associations. Here xform->op contains the required operation: rx/tx session/association add/update/removal.

This RFC contains:
- patch 1-2 is rte_security data structures declaration and documentation
- patches 3-5 MACSEC implementation for atlantic (Aquantia) driver, using new rte_security interface.
- patches 6-7 is a draft on how testpmd based invocations of rte_security API will look like

To be done/decide:
- add missing documentation and comments to all the structures
- full testpmd macsec API adoption
- ixgbe api adoptation
- decide on how to declare SA (Security Associations) auto rollover and some other important features.
- interrupt event callback detalization of possible macsec events. Notice that it is not a part of rte_security, but a part of rte_ethdev.
- add ability to retrieve MACSEC statistics per individual SC/SA.

Pavel Belous (7):
security: MACSEC infrastructure data declarations
security: Update rte_security documentation net/atlantic: Add helper functions for PHY access net/atlantic: add MACSEC internal HW data declaration and functions net/atlantic: implementation of the MACSEC using rte_security
interface
app/testpmd: macsec on/off commands using rte_security interface app/testpmd: macsec adding RX/TX SC using rte_security interface

 app/test-pmd/Makefile                              |    1 +
 app/test-pmd/cmdline.c                             |   20 +-
 app/test-pmd/macsec.c                              |  138 ++
 app/test-pmd/macsec.h                              |   14 +
 app/test-pmd/meson.build                           |    3 +-
 doc/guides/prog_guide/rte_security.rst             |    4 -
 drivers/net/atlantic/Makefile                      |    5 +-
 drivers/net/atlantic/atl_ethdev.c                  |  316 +---
 drivers/net/atlantic/atl_sec.c                     |  615 ++++++++
 drivers/net/atlantic/atl_sec.h                     |  124 ++
 drivers/net/atlantic/hw_atl/hw_atl_utils.h         |  116 +-
 drivers/net/atlantic/macsec/MSS_Egress_registers.h | 1498 ++++++++++++++++++
 .../net/atlantic/macsec/MSS_Ingress_registers.h    | 1135 ++++++++++++++
 drivers/net/atlantic/macsec/macsec_api.c           | 1612 ++++++++++++++++++++
 drivers/net/atlantic/macsec/macsec_api.h           |  111 ++
 drivers/net/atlantic/macsec/macsec_struct.h        |  269 ++++
 drivers/net/atlantic/macsec/mdio.c                 |  328 ++++
 drivers/net/atlantic/macsec/mdio.h                 |   19 +
 drivers/net/atlantic/meson.build                   |    6 +-
 drivers/net/atlantic/rte_pmd_atlantic.c            |  102 --
 drivers/net/atlantic/rte_pmd_atlantic.h            |  144 --
 drivers/net/atlantic/rte_pmd_atlantic_version.map  |   16 -
 lib/librte_security/rte_security.h                 |  143 +-
 23 files changed, 6080 insertions(+), 659 deletions(-)
 create mode 100644 app/test-pmd/macsec.c
 create mode 100644 app/test-pmd/macsec.h
 create mode 100644 drivers/net/atlantic/atl_sec.c
 create mode 100644 drivers/net/atlantic/atl_sec.h
 create mode 100644 drivers/net/atlantic/macsec/MSS_Egress_registers.h
 create mode 100644 drivers/net/atlantic/macsec/MSS_Ingress_registers.h
 create mode 100644 drivers/net/atlantic/macsec/macsec_api.c
 create mode 100644 drivers/net/atlantic/macsec/macsec_api.h
 create mode 100644 drivers/net/atlantic/macsec/macsec_struct.h
 create mode 100644 drivers/net/atlantic/macsec/mdio.c
 create mode 100644 drivers/net/atlantic/macsec/mdio.h
 delete mode 100644 drivers/net/atlantic/rte_pmd_atlantic.c
 delete mode 100644 drivers/net/atlantic/rte_pmd_atlantic.h
 delete mode 100644 drivers/net/atlantic/rte_pmd_atlantic_version.map
Signature · 1 line
2.7.4
#1 lore raw

RFC v2 1/7 security: MACSEC infrastructure data declarations

From: Pavel Belous <[email protected]>

This patch extends rte_security framework to support MACSEC operations.

---
 lib/librte_security/rte_security.h | 143 +++++++++++++++++++++++++++++++++++--
 1 file changed, 138 insertions(+), 5 deletions(-)
lib/librte_security/rte_security.h +138 -5
index aaafdfc..201319f 100644
@@ -29,6 +29,7 @@ extern "C" {
 #include <rte_mbuf.h>
 #include <rte_memory.h>
 #include <rte_mempool.h>
+#include <rte_ether.h>
 
 /** IPSec protocol mode */
 enum rte_security_ipsec_sa_mode {
@@ -215,11 +216,109 @@ struct rte_security_ipsec_xform {
 };
 
 /**
+ * MACSEC global configuration parameters
+ *
+ */
+struct rte_security_macsec_param {
+	uint8_t enabled;
+	uint32_t ingress_pn_threshold;
+	uint32_t egress_pn_threshold;
+	uint8_t interrupts_enabled;
+	/**< List of bypassed ethertypes */
+	uint32_t ctl_ether_types[8];
+};
+
+/**
+ * MACSEC SC (Secure Connection) parameters
+ *
+ */
+struct rte_security_macsec_txsc_param {
+	struct rte_ether_addr s_mac;
+	/**< local side mac address */
+	struct rte_ether_addr d_mac;
+	/**< remote side mac address */
+	uint64_t sci;
+	uint32_t tci;
+	uint32_t sa_num;
+	uint8_t encrypt;
+	uint8_t protect;
+	uint8_t key_len;
+	uint8_t auto_rollover_enabled;
+
+	uint32_t index;
+	uint32_t curr_an;
+};
+
+struct rte_security_macsec_rxsc_param {
+	struct rte_ether_addr s_mac;
+	struct rte_ether_addr d_mac;
+	uint64_t sci;
+	uint32_t tci;
+	uint32_t sa_num;
+	/**< remote side mac address */
+	uint8_t replay_protection;
+	/**< replay protection */
+	uint32_t anti_replay_window;
+	/**< anti replay window */
+	uint16_t port_ident;
+	/**< remote side port identifier */
+	uint8_t auto_rollover_enabled;
+	uint8_t validate_frames;
+
+	uint32_t index;
+};
+
+struct rte_security_macsec_sa_param {
+	uint8_t sa_idx;
+	uint8_t an;
+	uint32_t packet_number;
+	uint8_t key_len;
+	uint8_t key[32];
+};
+
+struct rte_security_macsec_capabilities {
+        /** Extended Packet Numbers (XPN)
+         *
+         * * 1: Extended (64 bit) packet numbers supported
+         * * 0: Extended (64 bit) packet numbers not supported
+         */
+        uint32_t xpn : 1;
+};
+
+/**
+ * Available operations over MACSEC instance
+ */
+enum rte_security_macsec_op {
+	RTE_SECURITY_MACSEC_OP_CONFIG = 0,
+
+	RTE_SECURITY_MACSEC_OP_ADD_TXSC,
+	RTE_SECURITY_MACSEC_OP_DEL_TXSC,
+	RTE_SECURITY_MACSEC_OP_UPD_TXSC,
+
+	RTE_SECURITY_MACSEC_OP_ADD_RXSC,
+	RTE_SECURITY_MACSEC_OP_DEL_RXSC,
+	RTE_SECURITY_MACSEC_OP_UPD_RXSC,
+
+	RTE_SECURITY_MACSEC_OP_ADD_TXSA,
+	RTE_SECURITY_MACSEC_OP_DEL_TXSA,
+	RTE_SECURITY_MACSEC_OP_UPD_TXSA,
+
+	RTE_SECURITY_MACSEC_OP_ADD_RXSA,
+	RTE_SECURITY_MACSEC_OP_DEL_RXSA,
+	RTE_SECURITY_MACSEC_OP_UPD_RXSA,
+};
+
+/**
  * MACsec security session configuration
  */
 struct rte_security_macsec_xform {
-	/** To be Filled */
-	int dummy;
+	enum rte_security_macsec_op op;
+	union {
+		struct rte_security_macsec_param config_options;
+		struct rte_security_macsec_txsc_param txsc_options;
+		struct rte_security_macsec_rxsc_param rxsc_options;
+		struct rte_security_macsec_sa_param sa_options;
+	};
 };
 
 /**
@@ -495,7 +594,42 @@ rte_security_attach_session(struct rte_crypto_op *op,
 }
 
 struct rte_security_macsec_stats {
-	uint64_t reserved;
+	/* Ingress Counters */
+	uint64_t in_ctl_pkts;
+	uint64_t in_tagged_miss_pkts;
+	uint64_t in_untagged_miss_pkts;
+	uint64_t in_notag_pkts;
+	uint64_t in_untagged_pkts;
+	uint64_t in_bad_tag_pkts;
+	uint64_t in_no_sci_pkts;
+	uint64_t in_unknown_sci_pkts;
+
+	/* Egress Counters */
+	uint64_t out_ctl_pkts;
+	uint64_t out_unknown_sa_pkts;
+	uint64_t out_untagged_pkts;
+	uint64_t out_too_long;
+
+	/* Ingress SA Counters */
+	uint64_t in_untagged_hit_pkts;
+	uint64_t in_not_using_sa;
+	uint64_t in_unused_sa;
+	uint64_t in_not_valid_pkts;
+	uint64_t in_invalid_pkts;
+	uint64_t in_ok_pkts;
+	uint64_t in_unchecked_pkts;
+	uint64_t in_validated_octets;
+	uint64_t in_decrypted_octets;
+	/* Egress SC Counters */
+	uint64_t out_sc_protected_pkts;
+	uint64_t out_sc_encrypted_pkts;
+	uint64_t out_sc_protected_octets;
+	uint64_t out_sc_encrypted_octets;
+	/* Egress SA Counters */
+	uint64_t out_sa_hit_drop_redirect;
+	uint64_t out_sa_protected2_pkts;
+	uint64_t out_sa_protected_pkts;
+	uint64_t out_sa_encrypted_pkts;
 };
 
 struct rte_security_ipsec_stats {
@@ -566,8 +700,7 @@ struct rte_security_capability {
 		} ipsec;
 		/**< IPsec capability */
 		struct {
-			/* To be Filled */
-			int dummy;
+			struct rte_security_macsec_capabilities caps;
 		} macsec;
 		/**< MACsec capability */
 		struct {
Signature · 1 line
2.7.4
#2 lore raw

RFC v2 2/7 security: Update rte_security documentation

In reply to Pavel Belous

From: Pavel Belous <[email protected]>

---
 doc/guides/prog_guide/rte_security.rst | 4 ----
 1 file changed, 4 deletions(-)
doc/guides/prog_guide/rte_security.rst +0 -4
index 7d0734a..4b9b186 100644
@@ -533,10 +533,6 @@ The ``rte_security_session_protocol`` is defined as
         /**< PDCP Protocol */
     };
 
-Currently the library defines configuration parameters for IPsec and PDCP only.
-For other protocols like MACSec, structures and enums are defined as place holders
-which will be updated in the future.
-
 IPsec related configuration parameters are defined in ``rte_security_ipsec_xform``
 
 .. code-block:: c
Signature · 1 line
2.7.4
#3 lore raw

RFC v2 3/7 net/atlantic: Add helper functions for PHY access

In reply to Pavel Belous

From: Pavel Belous <[email protected]>

Aquantia AQC107/AQC108 ethernet controllers includes MAC and PHY part. Some network features, like MACSec, are configured directly in the PHY part.

This patch adds helper functions for accessing PHY part via internal MDIO interface.

---
 drivers/net/atlantic/Makefile      |   2 +
 drivers/net/atlantic/macsec/mdio.c | 328 +++++++++++++++++++++++++++++++++++++
 drivers/net/atlantic/macsec/mdio.h |  19 +++
 drivers/net/atlantic/meson.build   |   1 +
 4 files changed, 350 insertions(+)
 create mode 100644 drivers/net/atlantic/macsec/mdio.c
 create mode 100644 drivers/net/atlantic/macsec/mdio.h
drivers/net/atlantic/Makefile +2 -0
index fc12e6a..6340588 100644
@@ -21,6 +21,7 @@ LDLIBS += -lrte_ethdev -lrte_net
 LDLIBS += -lrte_bus_pci
 
 VPATH += $(SRCDIR)/hw_atl
+VPATH += $(SRCDIR)/macsec
 
 #
 # all source are stored in SRCS-y
@@ -33,5 +34,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_llh.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils_fw2x.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_b0.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += rte_pmd_atlantic.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += mdio.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/atlantic/macsec/mdio.c new file +328 -0

328 lines not on this page · raw message

drivers/net/atlantic/macsec/mdio.h new file +19 -0
new file mode 100644
index 0000000..907f04f
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Aquantia Corporation
+ */
+
+#ifndef __MDIO_HH__
+#define __MDIO_HH__
+
+
+#include "../atl_types.h"
+#include "../hw_atl/hw_atl_utils.h"
+
+
+#define MMD_GLOBAL 0x1E
+
+
+int mdioRead(struct aq_hw_s *hw, unsigned int mmd, unsigned int addr, unsigned short int* data);
+int mdioWrite(struct aq_hw_s *hw, unsigned int mmd, unsigned int addr, unsigned short int data);
+
+#endif
drivers/net/atlantic/meson.build +1 -0
index 919d741..d1c66f4 100644
@@ -12,4 +12,5 @@ sources = files(
 	'hw_atl/hw_atl_utils_fw2x.c',
 	'hw_atl/hw_atl_utils.c',
 	'rte_pmd_atlantic.c',
+	'macsec/mdio.c',
 )
Signature · 1 line
2.7.4
#4 lore raw

RFC v2 4/7 net/atlantic: add MACSEC internal HW data declaration and functions

In reply to Pavel Belous

From: Pavel Belous <[email protected]>

MACSEC configuration is done by configuring multiple tables of MACSEC block:

- Ingress Pre-Security Classification table
- Ingress SC/SA/SAK lookup tables
- Ingress Post-Security Classification table
- Egress Packet Classifier table
- Egress Control Filter table
- Egress SC/SA/SAK lookup tables
- Ingress/Egress SC/SA/Common counters tables
- Some additional tables and spare registers

Each entry of the tables is distributed across a set of PHY registers.

This patch adds declarations for internal MACSEC HW structures and helper functions (HAL) for accessing these tables inside MACSEC block.

This HAL was automatically generated based on the RTL design of the MACSEC block.

---
 drivers/net/atlantic/Makefile                      |    1 +
 drivers/net/atlantic/macsec/MSS_Egress_registers.h | 1498 ++++++++++++++++++
 .../net/atlantic/macsec/MSS_Ingress_registers.h    | 1135 ++++++++++++++
 drivers/net/atlantic/macsec/macsec_api.c           | 1612 ++++++++++++++++++++
 drivers/net/atlantic/macsec/macsec_api.h           |  111 ++
 drivers/net/atlantic/macsec/macsec_struct.h        |  269 ++++
 drivers/net/atlantic/meson.build                   |    1 +
 7 files changed, 4627 insertions(+)
 create mode 100644 drivers/net/atlantic/macsec/MSS_Egress_registers.h
 create mode 100644 drivers/net/atlantic/macsec/MSS_Ingress_registers.h
 create mode 100644 drivers/net/atlantic/macsec/macsec_api.c
 create mode 100644 drivers/net/atlantic/macsec/macsec_api.h
 create mode 100644 drivers/net/atlantic/macsec/macsec_struct.h
drivers/net/atlantic/Makefile +1 -0
index 6340588..966676b 100644
@@ -35,5 +35,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils_fw2x.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_b0.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += rte_pmd_atlantic.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += mdio.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += macsec_api.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/atlantic/macsec/MSS_Egress_registers.h new file +1498 -0

1,498 lines not on this page · raw message

drivers/net/atlantic/macsec/MSS_Ingress_registers.h new file +1135 -0

1,135 lines not on this page · raw message

drivers/net/atlantic/macsec/macsec_api.c new file +1612 -0

361 lines not on this page · raw message

drivers/net/atlantic/macsec/macsec_api.h new file +111 -0

111 lines not on this page · raw message

drivers/net/atlantic/macsec/macsec_struct.h new file +269 -0

269 lines not on this page · raw message

drivers/net/atlantic/meson.build +1 -0
index d1c66f4..139cdec 100644

Lines of this file are not shown. View the raw message.

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

Signature · 1 line
2.7.4

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

#5 lore raw

RFC v2 5/7 net/atlantic: implementation of the MACSEC using rte_security interface

In reply to Pavel Belous

From: Pavel Belous <[email protected]>

---
 drivers/net/atlantic/Makefile                     |   2 +-
 drivers/net/atlantic/atl_ethdev.c                 | 316 ++---------
 drivers/net/atlantic/atl_sec.c                    | 615 ++++++++++++++++++++++
 drivers/net/atlantic/atl_sec.h                    | 124 +++++
 drivers/net/atlantic/hw_atl/hw_atl_utils.h        | 116 +---
 drivers/net/atlantic/meson.build                  |   4 +-
 drivers/net/atlantic/rte_pmd_atlantic.c           | 102 ----
 drivers/net/atlantic/rte_pmd_atlantic.h           | 144 -----
 drivers/net/atlantic/rte_pmd_atlantic_version.map |  16 -
 9 files changed, 802 insertions(+), 637 deletions(-)
 create mode 100644 drivers/net/atlantic/atl_sec.c
 create mode 100644 drivers/net/atlantic/atl_sec.h
 delete mode 100644 drivers/net/atlantic/rte_pmd_atlantic.c
 delete mode 100644 drivers/net/atlantic/rte_pmd_atlantic.h
 delete mode 100644 drivers/net/atlantic/rte_pmd_atlantic_version.map
drivers/net/atlantic/Makefile +1 -1
index 966676b..7aef5a1 100644
@@ -33,8 +33,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_llh.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_utils_fw2x.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += hw_atl_b0.c
-SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += rte_pmd_atlantic.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += mdio.c
 SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += macsec_api.c
+SRCS-$(CONFIG_RTE_LIBRTE_ATLANTIC_PMD) += atl_sec.c
 
 include $(RTE_SDK)/mk/rte.lib.mk
drivers/net/atlantic/atl_ethdev.c +55 -261

417 lines not on this page · raw message

drivers/net/atlantic/atl_sec.c new file +615 -0

615 lines not on this page · raw message

drivers/net/atlantic/atl_sec.h new file +124 -0

124 lines not on this page · raw message

drivers/net/atlantic/hw_atl/hw_atl_utils.h +4 -112

145 lines not on this page · raw message

drivers/net/atlantic/meson.build +3 -1
index 139cdec..986c6d6 100644
@@ -7,11 +7,13 @@ sources = files(
 	'atl_rxtx.c',
 	'atl_ethdev.c',
 	'atl_hw_regs.c',
+	'atl_sec.c',
 	'hw_atl/hw_atl_b0.c',
 	'hw_atl/hw_atl_llh.c',
 	'hw_atl/hw_atl_utils_fw2x.c',
 	'hw_atl/hw_atl_utils.c',
-	'rte_pmd_atlantic.c',
 	'macsec/mdio.c',
 	'macsec/macsec_api.c',
 )
+
+deps += ['security']
drivers/net/atlantic/rte_pmd_atlantic.c deleted +0 -102

102 lines not on this page · raw message

drivers/net/atlantic/rte_pmd_atlantic.h deleted +0 -144

144 lines not on this page · raw message

drivers/net/atlantic/rte_pmd_atlantic_version.map deleted +0 -16
deleted file mode 100644
index b16faa9..0000000
@@ -1,16 +0,0 @@
-DPDK_18.11 {
-
-	local: *;
-};
-
-EXPERIMENTAL {
-	global:
-
-	rte_pmd_atl_macsec_enable;
-	rte_pmd_atl_macsec_disable;
-	rte_pmd_atl_macsec_config_txsc;
-	rte_pmd_atl_macsec_config_rxsc;
-	rte_pmd_atl_macsec_select_txsa;
-	rte_pmd_atl_macsec_select_rxsa;
-};
-
Signature · 1 line
2.7.4
#6 lore raw

RFC v2 6/7 app/testpmd: macsec on/off commands using rte_security interface

In reply to Pavel Belous

From: Pavel Belous <[email protected]>

Here we create/get security mempool, get sec_ctx, and then request session creation with macsec specific session configuration.

encrypt and replay_protection parameters are really not a global macsec attributes, they are related to tx and rx security connection properties.

But we keep testpmd commands structure the same for now and will redesign it in later commits.

---
 app/test-pmd/Makefile    |  1 +
 app/test-pmd/cmdline.c   |  9 ++----
 app/test-pmd/macsec.c    | 82 ++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/macsec.h    | 12 +++++++
 app/test-pmd/meson.build |  3 +-
 5 files changed, 100 insertions(+), 7 deletions(-)
 create mode 100644 app/test-pmd/macsec.c
 create mode 100644 app/test-pmd/macsec.h
app/test-pmd/Makefile +1 -0
index d5258ea..14cd7f0 100644
@@ -37,6 +37,7 @@ SRCS-y += noisy_vnf.c
 SRCS-$(CONFIG_RTE_LIBRTE_IEEE1588) += ieee1588fwd.c
 SRCS-$(CONFIG_RTE_LIBRTE_BPF) += bpf_cmd.c
 SRCS-y += util.c
+SRCS-y += macsec.c
 
 ifeq ($(CONFIG_RTE_LIBRTE_PMD_SOFTNIC), y)
 SRCS-y += softnicfwd.c
app/test-pmd/cmdline.c +3 -6
index ffc8b70..10f48f8 100644
@@ -75,6 +75,7 @@
 #include "cmdline_mtr.h"
 #include "cmdline_tm.h"
 #include "bpf_cmd.h"
+#include "macsec.h"
 
 static struct cmdline *testpmd_cl;
 
@@ -14124,9 +14125,7 @@ cmd_set_macsec_offload_on_parsed(
 		return;
 
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
-#ifdef RTE_LIBRTE_IXGBE_PMD
-		ret = rte_pmd_ixgbe_macsec_enable(port_id, en, rp);
-#endif
+		ret = set_macsec_on_off(port_id, 1, en, rp);
 	}
 	RTE_SET_USED(en);
 	RTE_SET_USED(rp);
@@ -14221,9 +14220,7 @@ cmd_set_macsec_offload_off_parsed(
 		return;
 
 	if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MACSEC_INSERT) {
-#ifdef RTE_LIBRTE_IXGBE_PMD
-		ret = rte_pmd_ixgbe_macsec_disable(port_id);
-#endif
+		ret = set_macsec_on_off(port_id, 0, 0, 0);
 	}
 	switch (ret) {
 	case 0:
app/test-pmd/macsec.c new file +82 -0

82 lines not on this page · raw message

app/test-pmd/macsec.h new file +12 -0
new file mode 100644
index 0000000..42a534f
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2018 Intel Corporation
+ */
+
+#ifndef _TESTPMD_MACSEC_H_
+#define _TESTPMD_MACSEC_H_
+
+#include "testpmd.h"
+
+int set_macsec_on_off(portid_t port_id, int on, int en, int rp);
+
+#endif
app/test-pmd/meson.build +2 -1
index 6006c60..755bab2 100644
@@ -22,7 +22,8 @@ sources = files('cmdline.c',
 	'rxonly.c',
 	'testpmd.c',
 	'txonly.c',
-	'util.c')
+	'util.c',
+	'macsec.c')
 
 deps += ['ethdev', 'gro', 'gso', 'cmdline', 'metrics', 'meter', 'bus_pci']
 if dpdk_conf.has('RTE_LIBRTE_PDUMP')
Signature · 1 line
2.7.4
#7 lore raw

Re: [dpdk-dev] [RFC v2 6/7] app/testpmd: macsec on/off commands using rte_security interface

app/test-pmd/macsec.c line 31

Quoted 10 lines · On Fri, 25 Oct 2019 17:54:08 +0000 Pavel Belous <[email protected]>…
app/test-pmd/macsec.c new file +10 -0
+static struct rte_mempool *get_security_pool(struct rte_security_ctx *ctx)
+{
+	struct rte_mempool *mp = rte_mempool_lookup(TESTPMD_MEMPOOL_NAME);
+
+	if (!mp) {
+		unsigned int ssize = rte_security_session_get_size(ctx);
+
+		if (ssize) {
+			mp = rte_mempool_create("testpmd_security_pool",
+				1, /* One sesion */

spelling "session"

#8 lore raw

Re: [dpdk-dev] [RFC v2 6/7] app/testpmd: macsec on/off commands using rte_security interface

In reply to Pavel Belous

app/test-pmd/macsec.c line 50

Quoted 10 lines · On Fri, 25 Oct 2019 17:54:08 +0000 Pavel Belous <[email protected]>…
app/test-pmd/macsec.c new file +10 -0
+int set_macsec_on_off(portid_t port_id, int on, int en, int rp)
+{
+	struct rte_security_session_conf macsec_conf;
+	struct rte_security_ctx *ctx;
+	struct rte_mempool *mp;
+	int err = 0;
+
+	ctx = rte_eth_dev_get_sec_ctx(port_id);
+
+	if (!ctx) {

blank line between assignment and the if() statement is not necessary.

#9 lore raw

RFC v2 7/7 app/testpmd: macsec adding RX/TX SC using rte_security interface

In reply to Pavel Belous

From: Pavel Belous <[email protected]>

---
 app/test-pmd/cmdline.c | 11 +++++-----
 app/test-pmd/macsec.c  | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
 app/test-pmd/macsec.h  |  2 ++
 3 files changed, 63 insertions(+), 6 deletions(-)
app/test-pmd/cmdline.c +5 -6
index 10f48f8..a1f895c 100644
@@ -14304,13 +14304,12 @@ cmd_set_macsec_sc_parsed(
 	int ret = -ENOTSUP;
 	int is_tx = (strcmp(res->tx_rx, "tx") == 0) ? 1 : 0;
 
-#ifdef RTE_LIBRTE_IXGBE_PMD
 	ret = is_tx ?
-		rte_pmd_ixgbe_macsec_config_txsc(res->port_id,
-				res->mac.addr_bytes) :
-		rte_pmd_ixgbe_macsec_config_rxsc(res->port_id,
-				res->mac.addr_bytes, res->pi);
-#endif
+		config_macsec_txsc(res->port_id,
+                                res->mac) :
+	        config_macsec_rxsc(res->port_id,
+                                res->mac, res->pi);
+
 	RTE_SET_USED(is_tx);
 
 	switch (ret) {
app/test-pmd/macsec.c +56 -0

59 lines not on this page · raw message

app/test-pmd/macsec.h +2 -0
index 42a534f..e155937 100644
@@ -8,5 +8,7 @@
 #include "testpmd.h"
 
 int set_macsec_on_off(portid_t port_id, int on, int en, int rp);
+int config_macsec_txsc(portid_t port_id, struct rte_ether_addr mac);
+int config_macsec_rxsc(portid_t port_id, struct rte_ether_addr mac, uint16_t pi);
 
 #endif
Signature · 1 line
2.7.4
#10 lore raw
In reply to Pavel Belous

Hi Pavel,

Quoted 46 lines

From: Pavel Belous <[email protected]>

This RFC suggest possible API to implement generic MACSEC HW offload in DPDK infrastructure.

Right now two PMDs implementing MACSEC hw offload via private
API: ixgbe (Intel) and atlantic (Aquantia).

During that private API discussion it was decided to go further with well defined public API, based most probably on rte_security infrastructure.

Here is that previous discussion:

http://inbox.dpdk.org/dev/20190416101145.nVecHKp3w14Ptd_hne-DqHhKyzbre88PwNI-OAowXJM@z/

Declaring macsec API via rte_security gives a good data-centric view on parameters
and operations macsec supports. Old, pure functional API (basically ixbe only API) presented function calls with big argument lists which is hard to extend and analyse.

However, I'd like to note rte_security has to be used via explicitly created mempools - this hardens abit the usage.
It also may be hard to extend the structures in the ABI compatible way.

One of the problems with MACSEC is that internally implementation and hardware
support could be either very simple, doing only endpoint encryption with a single TX SC (Secure Connection), or quite complex, capable to do flexible filtering and SC matching based on mac, vlan, ethertype and other.

Different macsec hardware supports some custom features and from our experience
users would like to configure these as well. Therefore there will probably be needed a number of PMD specific macsec operators support.

Examples include: custom in-the-clear tag (matched by vlan id or mask), configurable internal logic to allow both secure and unsecure traffic, bypass filters on specific ethertypes.
To support such extensions, suggest use rte_security_macsec_op enum with vendor specific operation codes.

In context of rte_security, MACSEC operations should normally be based on security session create and update calls.

Quoted 7 lines

Session create is used to setup overall session. Thats equivalent of old macsec enable operation.

Session update is used to update security connections and associations. Here xform->op contains the required operation: rx/tx session/association add/update/removal.

The patches look good from rte_security perspective. You can send the formal Patches for 20.05 window.